Friends,
I searched for the solution but couldn't get.
Actually, I wanted disable one Menu Item in Menu Button based on some condition.
Can this be done. I can do other way round that is, write code in that menu item to restrict its functionality.
Please guid better way.
Thx,
Sanjeev
0
Comments
Do one thing. make another menu button(MB2) and make the menu item disable (which u want to disable by making visible to No). put this menu button on ur previos menu button(MB1). now add following line of code to OnOpen Form:
if <Condition> Then begin
Currform.MB1.visible := False;
Currform.MB2.visible := True;
end
else begin
Currform.MB1.visible := true;
Currform.MB2.visible := false;
end;
Regards,
Gaurav
Consultant-Microsoft Dynamics Nav
For example, to disable a menu button that has the value of the Name property set to btnCustomer, you would use the following command:
CurrForm.btnCustomer.ENABLED(FALSE);
Unfortunately, there is not a method to dynamically control the individual menu items of a menu button. However, it would be possible to create two different menu buttons with different Name property values. These two button controls could then be stacked on top of each other and trigger code added to the form to make one button visible and one button not visible, based upon the desired criteria.
For example, to control which menu button is displayed, based on the existence of a customer email address, where the button controls were named btnCustomer1 and btnCustomer2, you would use the following code in the OnAfterGetCurrRecord trigger:
IF "E-Mail" = '' THEN BEGIN
CurrForm.btnCustomer1.VISIBLE(TRUE);
CurrForm.btnCustomer2.VISIBLE(FALSE);
END ELSE BEGIN
CurrForm.btnCustomer1.VISIBLE(FALSE);
CurrForm.btnCustomer2.VISIBLE(TRUE);
END;
**EDIT**
Ooops already posted
http://www.BiloBeauty.com
http://www.autismspeaks.org
I feel u didnt get my problem. I wanted to enable/disable the Menu Item in Menu Button and not Menu Button. I know menu button can be enabled/disabled. I wanted to enable/disable the 1 or more Menu Items in Menu Button.
RIS Plus, LLC
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
i have understood ur proble and already sent u the solution 4 the same. agin i m sending:
make another menu button(MB2) and make the menu item disable (which u want to disable by making visible to No(untick it)) . put this menu button on ur previos menu button(MB1). now add following line of code to OnOpen Form:
if <Condition> Then begin
Currform.MB1.visible := False;
Currform.MB2.visible := True;
end
else begin
Currform.MB1.visible := true;
Currform.MB2.visible := false;
end;
Regards,
Gaurav
Consultant-Microsoft Dynamics Nav
Thx for ur efforts of putting it again. Your suggestion will work only when it will be only 1 or 2 conditions. But think the case where for different reasons (multiple conditions) will be there then I can not have multiple buttons. I should be able to simply enable/disable the items based on multiple conditions.
for example:
condition 1 will disable menu item 2
condition 2 will disable menu item 5
condition 3 will disable menu item 8
condition 4 will disable menu item 10
I hope u got what I mean to say.
We should all be able to simply enable/disable individual menuitems ... but we can't. It is so by design.
I think you have to live with it. Sorry
If you want something that looks like a dynamic menubutton you will have to use the trick posted by Guarav.
RIS Plus, LLC
RIS Plus, LLC
U got it wrong. M not under estimating anyone or thinking people are fool here. I thought people miss-understood my query so written it again.
Try this
Not exactly you want but ...
Trigger onPush of ComandButton
var bool1,bool2,bool3 - boolean - or your conditions
var OptionString, NewString - text 250
A post was made a while ago about security roles and how the ones from Microsoft don't seem to work. A idea was put forth that you should start out with giving the users everything. Not just Table/Form/Report 0, but list every table/form/report/codeunit/etc by number and granting permissions. Then as you want to restrict users and tighten security you take away the permissions from all users and create a new group of users that have these permissions.
I was testing this out and found it works very well, especially if you just remove permissions for the forms they have no need to see.
(And now I get to the point!)
If what you are trying to do is not allow the users to see a form/report/dataport all you have to do is take away their permission to view that object and they cannot see it in the Menu. This makes their security the condition and it does it automatically without extra coding. If their security changes in the future to allow them that object then it will be back on their menu.
Of course it is a little more involved to set up but it does tighten security a lot in the process and who doesn't want that?
Hopefully this helps,
Joe
http://www.interdynbmi.com