Particular Column Value modification allowance

navuser1navuser1 Member Posts: 1,329
edited 2016-04-27 in NAV Three Tier
Hi,

I am working on NAV 2013 R2 Database.

I want that No one can change the Document (record) if this Document (record) carries a TRUE value in a Boolean field. Only those can change who has proper rights in USER SETUP TABLE (ID 91).

But at the same time I have to give a provision to the end user to change the Posting in same Record if required, but can not change other field level records in any circumstances.

To achieve this I have added the following code under the Table/Page Triggers.....
TABLE----
OnModify()
IF Approved AND (xRec."Posting Date" = Rec."Posting Date") THEN BEGIN
  UserSetup.GET(USERID);
  UserSetup.TESTFIELD(Authorized,TRUE);
END;
PAGE----
Posting Date - OnValidate()
CurrPage.UPDATE(TRUE);

This is working absolutely fine. Is there any other way I can manage the same ?
Kindly inform.
Now or Never

Answers

  • osimrenosimren Member Posts: 29
    You could potentially add a date variable to the page and have validation code on that one to update the record without running the OnModify trigger.
    Not sure if it would be better thought.... :smile:
  • navuser1navuser1 Member Posts: 1,329
    I have to execute the table OnModify trigger because I don't want to allow any end users* to modify/change the other field's value in spite of Posting Date field.

    [* except system admin/Super user]
    Now or Never
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    It seems to be quite easy to workaround - change some fields, then change
    the Posting Date to +1 day, and then change the posting date back.

    Just a thought.

    If you're looking for other places where to put your code you don't have many options in NAV2013R2. You'd probably need to stick to modification of OnModify trigger in the table, but I'd say create a new function in custom codeunit and in OnModify trigger on the table just call that function, or even better put your checking code in the OnRun trigger in your codeunit and call CODEUNIT.RUN(yourcodeunitid, rec) in OnModify trigger.

    This is to minimize standard table modifications.

    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.