Security to push button in Vendor Card

souravbsouravb Member Posts: 135

Hi,
I have created a menu button in vendor card called 'Calculate Score". I want only user having id 'SB' will be able to calculate the score when the button is pushed. For other users the system will throw authorization error. I have written a code like this:


IF CONFIRM('Do You want to calculate score?',TRUE) THEN BEGIN
GVUserSetup.GET(GVUserSetup."User ID");
IF GVUserSetup.FIND('-') THEN
IF GVUserSetup."User ID"<> 'SB' THEN BEGIN
ERROR('You are not authorized to calculate vendor score');
EXIT;
END;

when i run the card and push the button for all users the error is coming as such "User Setup User ID " does not not exist"
How do i solve it. Plz help.

Comments

  • SunsetSunset Member Posts: 201
    Keep it simple :)

    First line

    IF USERID <> 'SB' THEN
    ERROR('Errormessage');

    This makes sure that if the user is not SB an error occurs


    Second line. (Navision will have stopped if the error kicked in)

    IF CONFIRM('Do You want to calculate score?',TRUE) THEN
    Callcalculation;
    Don't just take my word for it, test it yourself
  • jlandeenjlandeen Member Posts: 524
    I completely agree that it should be kept as simple as possible. However I always question harcoding any checks like this. Could you add a field to the User Setup table that determines whether or not they're allowed to run this calculation. This will ensure that the client can manage this without having to push this back to a developer.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • DenSterDenSter Member Posts: 8,305
    It depends on what the requirement is. If you want more than one person to be able to run that calculation, then you could add a checkbox to the user setup table. If there's only one person in the entire company that whouls be able to do this, then you'd add a field to a functional setup table. So if this is some sort of sales calculation, you'd add a 'Calculation User ID' field to the Sales & Receivables Setup table. Then you'd program a check into the calculation to either check if the user setup record has the checkmark, or if the user running the process has the same user ID as in the sales setup.
Sign In or Register to comment.