sskoparde
1st August 2015, 07:55
What is the procedure to disable the menu based on condition.
We want to disable Purchase order additional charges menu after approval process

sam291091
1st August 2015, 08:53
Hi,

Try to Remove all form commands from that menu, then it will automatically remove or disable that particular menu

Remove form commands :
after.form.read:
if condition then
remove.form.commands (string command,...)
endif

bhushanchanda
1st August 2015, 09:50
Hi,

Try to Remove all form commands from that menu, then it will automatically remove or disable that particular menu

Remove form commands :
after.form.read:
if condition then
remove.form.commands (string command,...)
endif


Do not use this. There is no way to restore or create new form command again once removed.

Though, I guess the requirement is to disable the standard form command which means there are the following alternatives -

1. If you have standard script you can use UI Template and use

function extern boolean form.command.is.allowed () and then use disable.commands() to disable based on the return value of the function.

2. If you do not own the source code, and if you are on the latest porting set, you can create a UE DLL for the additional charges table and in ue.before.before.save.. section, you can check the PO status and stop the saving in case if its approved.

3. If you do not own source code and if you are not on the latest porting set, you can create a table data authorization for additional charges table and make it read only if the order is approved
(In this case, you must have a field indicating the PO status in this table)

4. You can create a wrapper script for standard session. And handle the form command in there.

The best possible way to take care of this is, regardless of porting sets and all is, replace the form command with your own session. Now, if the user clicks on the form command, it will call your custom session which will do the PO status check in before.program section. If its approved you will use exit() if not, you can call start.session() to start the standard Additional Charges session and kill your custom session. This will take care of your requirement without any major customization.

sam291091
1st August 2015, 10:01
Hi bhushanchanda,
You are right but lets say 10 form command is there in one particular Manu then we need write 10 times form.command.allow, otherwise we can use "disable.commands/enable commands" in particular condition.

bhushanchanda
1st August 2015, 10:09
Hi,

If 10 form commands have a single rule to apply you don't need to write form.command.is allowed 10 times, just call once for one of the 10 form commands and based on the return value, use
disable.commands("command1","command2"...)

Else, a simple condition will do

after.form.read:
if condition then
disable.commands("command1","command2"...)
endif

But, the reason to use form.command.is allowed() comes up when you have different conditions for different commands.