Adding and change value

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

Does anyone can help this issue?

thx

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

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?

Yes it is in ABC appā€¦

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

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ā€™).

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.

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

thx

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

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

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

joe

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

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)

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

Put it to the accepted event of the button.

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

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

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

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ā€¦