C/AL code for specific user

I need only specific user to update the sales price.In the user setup table i have created a boolean .only the person with that boolean tick can update the sales price.how to write c/al code for this?
thanks
gugan

Answers

  • guganvarman_21guganvarman_21 Member Posts: 16
    please answer its emergency
  • KlappspatenKlappspaten Member Posts: 22
    edited 2019-10-09
    In the beginning of the OnValidate trigger of the field, get the User Setup Record for the current user
    UserSetup.GET(USERID)
    
    Then check if your new boolean field is activated, if it's not throw an error.
    IF NOT UserSetup."Boolean Field" THEN
        ERROR('Your text as textconstant here')
    

    Remember to create a local variable of type Record and Subtype 91 (User Setup Table) for this purpose.
  • guganvarman_21guganvarman_21 Member Posts: 16
    Thanks Klappspaten.
    There are 4 users in the user set up and i need only particular users to update the price.In that case how can i give privilege to that users alone
  • KlappspatenKlappspaten Member Posts: 22
    edited 2019-10-09
    This way you did it.
    The code I provided does the following:

    1. The OnValidate trigger of the price field is invoked
    2. Get the User Setup Record for the user which invoked the trigger
    3. Check if the user has the priviledge to change the price
    4. The user has no priviledge/flag? Throw an error.

    If you need to give other users the priviledge to modify the price, or want to remove the priviledge for a user, activate(deactivate your new boolean field at User Setup for this user.
  • krikikriki Member, Moderator Posts: 9,094
    [Topic closed because of double posting]
    See https://forum.mibuso.com/discussion/74318

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


This discussion has been closed.