Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

disabling form controls for specific user

Posted on by 1,534

hi expert, i wan to disabled some controls (creditmax, and MandatoryCreditLimit) disabled for some users, for this i just do following code in init method of custTable.

SecurityRole role;
 role.Name == 'MycustomRole';


if(role)
{
custTable_ds.object(fieldNum(CustTable, creditmax)).enabled(false);
custTable_ds.object(fieldNum(CustTable, MandatoryCreditLimit)).enabled(false);

}

else

{

custTable_ds.object(fieldNum(CustTable, creditmax)).enabled(true);
custTable_ds.object(fieldNum(CustTable, MandatoryCreditLimit)).enabled(true);

}

it working ,but for all user the above mentioned controls are disabled, while i just want for specific user role,

how it can be.

*This post is locked for comments

  • munsif Profile Picture
    munsif 1,534 on at
    RE: disabling form controls for specific user

    in my current situation requirement only for current form,

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: disabling form controls for specific user

    Do you really want to restrict the access in this form only? Do you want to allow users to change these fields in other forms? If not, you should think about underlying fields instead of individual forms and form controls.

  • munsif Profile Picture
    munsif 1,534 on at
    RE: disabling form controls for specific user

    ok great, so basically what i should do in that case, just drag mentioned controls in readnode of custTable form,can you please guide me briefly.

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: disabling form controls for specific user

    Not at all. Do you see all forms in standard AX duplicated for each role? Of course not.

    What you seems to want to is to configure MycustomRole not to have write permissions for CustTable.creditmax and CustTable.MandatoryCreditLimit fields.

  • munsif Profile Picture
    munsif 1,534 on at
    RE: disabling form controls for specific user

    yes you are right Martin, but in that case for all my custom roles the custTable form should be duplicated,which is long story, because if i make changes in form for one mycustom role, the same changes will be replicated for all roles.am i right?

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: disabling form controls for specific user

    Why don't you just configure read/write permissions using role-based security, instead of writing your own code for that?

  • munsif Profile Picture
    munsif 1,534 on at
    RE: disabling form controls for specific user

    thanks ,for your quick response,my requirement is  ,on custTable form  credit limit and mandatory credit limit check box  control disabled, for  my custom role, so how it can be achieved through code,

  • jasman Profile Picture
    jasman 1,411 on at
    RE: disabling form controls for specific user

    The

    If(role)

    check is obviously the source of the problem.

    Is what you show your actual code ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans