Enable/Disable Menu Items in Menu Button

sanjeevasawale
Member Posts: 63
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
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
-
Hi,
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,
GauravGaurav Sharma,
Consultant-Microsoft Dynamics Nav0 -
Assign a value to the Name property of a command or menu button then you can dynamically set the Enabled or Visible properties of the control in the trigger code using C/AL commands.
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 posted0 -
Friends,
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.0 -
You can't.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
-
nicht immer, aber immer oefter.0
-
hi,
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,
GauravGaurav Sharma,
Consultant-Microsoft Dynamics Nav0 -
Dear Gaurav,
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.0 -
sanjeevasawale wrote:I should be able to simply enable/disable the items based on multiple conditions.
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. SorryNo support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
sanjeevasawale wrote:<snip>
I should be able to simply enable/disable the items based on multiple conditions.
</snip>
If you want something that looks like a dynamic menubutton you will have to use the trick posted by Guarav.0 -
Do I hear an echo ;-)No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
-
Hey Black ?,
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.0 -
sanjeevasawale wrote:
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.
Try this
Not exactly you want but ...
Trigger onPush of ComandButton
var bool1,bool2,bool3 - boolean - or your conditions
var OptionString, NewString - text 250OptionString:=''; IF bool1 THEN IF OptionString='' THEN OptionString:='menu 1' ELSE OptionString:=OptionString+',menu 1'; IF bool2 THEN IF OptionString='' THEN OptionString:='menu 2' ELSE OptionString:=OptionString+',menu 2'; IF bool3 THEN IF OptionString='' THEN OptionString:='menu 3' ELSE OptionString:=OptionString+',menu 3'; NewString := SELECTSTR(STRMENU(OptionString),OptionString); CASE NewString OF 'menu 1':BEGIN MESSAGE('Menu 1 action. May be open list form'); END; 'menu 2':BEGIN MESSAGE('Menu 2 action.'); END; 'menu 3':BEGIN MESSAGE('Menu 3 action.'); END; END;
0 -
I'm not sure exactly what you are looking for but it sounds like you want to disable menu items for certain users which sounds like security to me.
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,
Joe0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions