How to Make Visible Command Button

Stivan_dsouza21
Member Posts: 218
How to Make Visible Command Button to some user.
1) I have created a a new role. If that role exist in that user id. then only the Command Button should get visible.
2) i have created the 2 command button as "DONE" and "EDIT"
3) i have written code as follows:
Form - OnOpenForm Trigger
user.GET(USERID);
memberof.RESET;
memberof.SETRANGE(memberof."User ID",USERID);
memberof.SETRANGE(memberof."Role ID",'TC UPDATION');
IF memberof.FINDFIRST THEN
BEGIN
CurrForm.Done.Visible:= FALSE;
CurrForm.Edit.Visible:= FALSE;
END;
But the above code is not working
can somebody help me out.
1) I have created a a new role. If that role exist in that user id. then only the Command Button should get visible.
2) i have created the 2 command button as "DONE" and "EDIT"
3) i have written code as follows:
Form - OnOpenForm Trigger
user.GET(USERID);
memberof.RESET;
memberof.SETRANGE(memberof."User ID",USERID);
memberof.SETRANGE(memberof."Role ID",'TC UPDATION');
IF memberof.FINDFIRST THEN
BEGIN
CurrForm.Done.Visible:= FALSE;
CurrForm.Edit.Visible:= FALSE;
END;
But the above code is not working
can somebody help me out.
Thanks & Regards,
Stivan D'souza
Stivan D'souza
0
Comments
-
Should it be
CurrForm.Done.Visible:= TRUE;
CurrForm.Edit.Visible:= TRUE;
If role found?0 -
It does not work if you use Windows logins.
Give this one a look : http://www.mibuso.com/forum/viewtopic.php?t=38353Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I have done the necessary Changes but its saying
Microsoft Dynamics NAV Classic
You have specified an unknown variable.
Done
Define the variable under 'Global C/AL symbols'.
OK
Thanks & Regards,
Stivan D'souza0 -
Did you set name fields for buttons?0
-
Its a Command Button.Thanks & Regards,
Stivan D'souza0 -
sorry..
I mean Name property for command button..0 -
Yes.
But if role is not specified then also its visible.Thanks & Regards,
Stivan D'souza0 -
Thanks Mohana.
Its Done.
user.GET(USERID);
memberof.RESET;
memberof.SETRANGE(memberof."User ID",USERID);
memberof.SETRANGE(memberof."Role ID",'TC UPDATION');
IF memberof.FINDFIRST THEN
BEGIN
CurrForm.Done.VISIBLE:= TRUE;
END ELSE
CurrForm.Done.VISIBLE:= FALSE;
user.GET(USERID);
memberof.RESET;
memberof.SETRANGE(memberof."User ID",USERID);
memberof.SETRANGE(memberof."Role ID",'TC UPDATION');
IF memberof.FINDFIRST THEN
BEGIN
CurrForm.Edit.VISIBLE:= TRUE;
END ELSE
CurrForm.Edit.VISIBLE:= FALSE;Thanks & Regards,
Stivan D'souza0 -
Why do you need 2 times?
user.GET(USERID); memberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); IF memberof.FINDFIRST THEN BEGIN CurrForm.Done.VISIBLE:= TRUE; CurrForm.Edit.VISIBLE:= TRUE; END ELSE BEGIN CurrForm.Done.VISIBLE:= FALSE; CurrForm.Edit.VISIBLE:= FALSE; END;
0 -
Thanks Mohana i have necessary changes as per request and it working fine.
=D>Thanks & Regards,
Stivan D'souza0 -
Or
memberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= memberof.FINDFIRST; CurrForm.Edit.VISIBLE:= memberof.FINDFIRST;
:thumbsup:0 -
mohana_cse06 wrote:Or
memberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= memberof.FINDFIRST; CurrForm.Edit.VISIBLE:= memberof.FINDFIRST;
:thumbsup:memberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= memberof.FINDFIRST; CurrForm.Edit.VISIBLE := currform.done.visible
But I once created a function in a codeunit that is "hasrole"
The same code applies, but a parameter with the rolename and a boolean return. Bam you can use it anywhere0 -
mohana_cse06 wrote:
memberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= memberof.FINDFIRST; CurrForm.Edit.VISIBLE:= memberof.FINDFIRST;
:thumbsup:Sog wrote:I prefer only one findfirstmemberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= memberof.FINDFIRST; CurrForm.Edit.VISIBLE := currform.done.visible
or this :Pmemberof.RESET; memberof.SETRANGE(memberof."User ID",USERID); memberof.SETRANGE(memberof."Role ID",'TC UPDATION'); CurrForm.Done.VISIBLE:= NOT memberof.ISEMPTY; CurrForm.Edit.VISIBLE := currform.done.visible
Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0
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