Setting permission to a specific field

raja123raja123 Posts: 29Member
Does anyone know if it is possible to restrict the access to a field and not to the entire table?
For example: Only user 'x' have access to all fields of the table, the others cannot have access to one of the fields of this table.

Answers

  • AlexeyShaminAlexeyShamin Posts: 7Member
    edited 2019-05-14
    There is no such possibility in standard NAV. This can be implemented by modifications.

    But the restriction on the reading of the field cannot be realized even with the modification.

    If necessary I can describe the implementation in NAV 2017
  • raja123raja123 Posts: 29Member
    Yeah, please explain me AlexeyShamin
  • AlexeyShaminAlexeyShamin Posts: 7Member
    Small example for Update Event

    1. Create Table for restricted fields. Table Fields:
    User ID - Code(50)
    Table ID - integer
    Field ID - integer
    Key - User ID, Table ID, Field ID


    2. create subscription function. Event - Subscriber, EventPublisherObject - Codeunit ApplicationManagement, EventFunction - OnAfterOnDatabaseModify.

    Function Parameters:
    VAR RecRef - RecordRef

    Function Variables:
    FieldsRec - Record (Table from step 1)
    xRecRef - RecordRef
    FieldRef - FieldRef
    xFieldRef - FieldRef

    Code:
    xRecRef.GET(RecRef.RECORDID);

    FieldsRec.RESET;
    FieldsRec.SETRANGE("User ID", USERID);
    FieldsRec.SETRANGE("Table ID", RecRef.NUMBER);
    IF FieldsRec.FINDSET THEN
    REPEAT
    FieldRef := RecRef.FIELD(FieldsRec."Field ID");
    xFieldRef := xRecRef.FIELD(FieldsRec."Field ID");
    IF FieldRef.VALUE <> xFieldRуf.VALUE THEN
    ERROR('You do not have permission to change the field');
    UNTIL FieldsRec.NEXT = 0;


Sign In or Register to comment.