Check Permission for a spezific Record

Hi guys,

i want to check if Users can modify a contact. Every Contact has a Resp. Center Code. The user has Grand Read/Write Permissions for the Contact Table without a SecurityFilter but no Read/Wirte Permission for every Resp. Center. There Exist a Security Filter for a Range of Codes like 1...2|4|5.

So Now he wants to modify a Contact which have the Resp Center Code 3.

CheckFunction:

//Check if User allowed to Change Contact on RespCenter 

ResponsibilityCenter.RESET;
ResponsibilityCenter.SETRANGE(Code,'3');
IF ResponsibilityCenter.READPERMISSION THEN
  EXIT(TRUE)
ELSE
  EXIT(FALSE);

Any good Idea why this doesnt works?

Best Answer

  • Martin_FörsterMartin_Förster Member Posts: 55
    Answer ✓
    So this is the Way how it works. The Strange Thing is the "SETPERMISSIONFILTER", my Opinion was, it works only in 2009!?!?!



    IF COPYSTR(Contact."Responsibility Center",3,6) <> '990100' THEN
      EXIT(TRUE);
    
    //Check if User allowed to Change Contact on RespCenter (*990100)
    ResponsibilityCenter.RESET;
    ResponsibilityCenter.SETPERMISSIONFILTER;
    IF ResponsibilityCenter.FINDSET THEN BEGIN
      HelpCode := RespCenterManagement.GetFullRespCenterState(Contact."Responsibility Center");
      Repeat
        IF HelpCode = ResponsibilityCenter.Code THEN
          EXIT(TRUE);
      UNTIL ResponsibilityCenter.NEXT = 0;
      EXIT(FALSE)
    END ELSE
      EXIT(FALSE);
    

Answers

  • HannesHolstHannesHolst Member Posts: 119
    Hi,

    READPERMISSIONS determines if the user is allowed to read a record filtered using a FILTERGROUP (Security filter).

    For your requirement check function "GetSalesFilter" of codeunit User Setup Management (ID 5700).

    The function will deliver a filter-text of allowed responsibility center.
  • Martin_FörsterMartin_Förster Member Posts: 55
    Answer ✓
    So this is the Way how it works. The Strange Thing is the "SETPERMISSIONFILTER", my Opinion was, it works only in 2009!?!?!



    IF COPYSTR(Contact."Responsibility Center",3,6) <> '990100' THEN
      EXIT(TRUE);
    
    //Check if User allowed to Change Contact on RespCenter (*990100)
    ResponsibilityCenter.RESET;
    ResponsibilityCenter.SETPERMISSIONFILTER;
    IF ResponsibilityCenter.FINDSET THEN BEGIN
      HelpCode := RespCenterManagement.GetFullRespCenterState(Contact."Responsibility Center");
      Repeat
        IF HelpCode = ResponsibilityCenter.Code THEN
          EXIT(TRUE);
      UNTIL ResponsibilityCenter.NEXT = 0;
      EXIT(FALSE)
    END ELSE
      EXIT(FALSE);
    
Sign In or Register to comment.