Adding and change value


#1

Hi,
I have a browse menu and I need to make action of a button (approve button) so if the button is selected the button will change the field value into 1 and disable the change and delete button and also change the button string value into unapprove . But if the button were selected again the value will be return into approve and the value change into 0 and the button of change and delete will be return to enable again . can anyone can help ?

thx


#2

Does anyone can help this issue?

thx


#3

What is a problem?

if the button is selected the button will change the field value into 1 and disable the change and delete button and also change the button string value into unapprove

if selected() = ?btnApprove
  if ?btnApprove{prop:text} = 'Approve'
    field:value = 1
    disable{?btnChange)
    disable(?btnDelete)
    ?btnApprove{prop:text} = 'Unapprove'
  else
     !- do it yourself
  end
end

#4

Hi Joe -

There’s some stuff here that would kind of depend on the underlying data, rather than just coding a button. Do you intend to enforce these rules (being allowed to modify/delete) elsewhere in your application? Will any other apps ever use the same data?

Is this an ABC app?


#5

Yes it is in ABC app…


#6

Hi,
I try this script but still not working…
if selected() = ?button8
if ?button8{prop:text} = ‘Approve’
PRh:sts = 1
disable(?Change:4)
disable(?Delete:4)
?button8{prop:text} = ‘Unapprove’
else
if ?button8{prop:text} = ‘UnApprove’
PRh:sts = 0
enable(?Change:4)
enable(?Delete:4)
?button8{prop:text} = ‘Approve’
end
end
end


#7

not working what? Maybe this - PRh:sts = 1? or this - disable(?Change:4)? Or not working everything?
Pay attention that this code will executed only if ?button8 is selected.
Also in one place you set one text (‘Unapprove’), in another you test it against different text (‘UnApprove’).


#8

If you want to disable the delete and change button in an ABC browse you need to embed your logic in the browse UpdateWindow method after the parent call. This method is going to enable disable those buttons automatically. Test your condition and enable/disable appropriately.
The other option is to clear the browse classes control properties for delete/change.
Add the following with your enable/disable lines in your example above change to:
clear(BRW1.ChangeControl)
clear(BRW1.DeleteControl)
and
BRW1.ChangeControl = ?Change:4
BRW1.DeleteControl = ?Delete:4

Replace BRW1 with your browse class name.


#9

Dear Mike,
it is not working everything, Do I put mistake script? and it is after the button were selected…

thx


#10

Dear Rick,
Does it working after the button of change and delete were selected? cause I need the condition that if the sts field value is 1 or the button string were unapproved both button will be disable.

thx


#11

You need to put your code in brwx.NewSelection after parent. That way you can change the buttons per row. using row fields


#12

Dear seanh,
could you tell me the code is ? thx

joe


#13

I think Something like this:

IF PRh:sts = 1
disable(?Change:4)
disable(?Delete:4)
?button8{prop:text} = ‘Unapprove’
else
?button8{prop:text} = ‘UnApprove’
end


#14

Hi @joekanan ,

As for my understanding, you are trying to create a browse for purchases that the user can “Approve” or “Unapprove” a purchase record right?

If I hit it, this is what will I do…

:point_down: Borrowing and editing the code from seanh
IF PRh:sts = 1
disable(?Change:4)
disable(?Delete:4)
?button8{prop:text} = ‘Unapprove’
else
enable(?Change:4)
enable(?Delete:4)
?button8{prop:text} = ‘Approve’
end

Embed it to the accepted event of your browse. See sample image below


Just make sure the PRh:sts is added as a column in your browse, if not it must be binded(Actions > Hot Fields tab)


#15

where should I put the command of changing value of PRH:sts so ‘Approve’ will give PRH:sts=1 and ‘UnApprove’ will give the PRH:sts=0

thx


#16

Put it to the accepted event of the button.


#17

Put this codes after your codes for changing the value.
Sample :point_down:
GET(YourTable,YourKey)
IF NOT ERRORCODE()
! Your codes
PUT(YourTable)
END
Add this here :point_down:
BRWn.ResetQueue(1)
BRWn.ResetFromView
DISPLAY


#18

Dear Romual,
Does the script located after

IF PRh:sts = 1
disable(?Change:4)
disable(?Delete:4)
?button8{prop:text} = ‘Unapprove’
else
enable(?Change:4)
enable(?Delete:4)
?button8{prop:text} = ‘Approve’
end

and are all of those script will be added or only one of them?
thx


#19

joekanan,

This :point_down: script is for the browse accepted event.
IF PRh:sts = 1
disable(?Change:4)
disable(?Delete:4)
?button8{prop:text} = ‘Unapprove’
else
enable(?Change:4)
enable(?Delete:4)
?button8{prop:text} = ‘Approve’
end

And this :point_down: is for ?Button8 accepted event
GET(YourTable,YourKey)
IF NOT ERRORCODE()
IF PRh:sts = 1
PRh:sts = 0
ELSE
PRh:sts = 1
END
PUT(YourTable)
END
BRWn.ResetQueue(1)
BRWn.ResetFromView
DISPLAY


#20

I got errors on
BRWn.ResetQueue(1) --> field not found ResetQueue
BRWn.ResetFromView --> field not found
unknown procedure label…
can you tell me why?

thx…