Prevent user triggered changes via Table Subscriber

jordi79jordi79 Member Posts: 277
Hi,
I am trying to prevent user triggered changes to a Vendor table. Changes done indirectly is allowed e.g. Changes done via C/AL MODIFY, INSERT or DELETE statements are allowed.

I am looking at the triggers for the Vendor table, but I cannot find any suitable events. The most suitable I can find is to use the OnAfterModifyEvent and check the RunTrigger value. But, if a MODIFY(TRUE) statement is called, this will trigger this event too.

Answers

  • ResolusResolus Member Posts: 40
    Very special request...

    As you said, you can just use the onbeforemodify, onbeforeinsert, and onbeforedelete triggers and indeed check the RunTrigger value.
    When C/AL runs a MODIFY(TRUE) statement that will also be true.
    You could work around it by adding an additional Boolean field in the table, AllowCALChange.

    Whenever your subscriber is triggered, you could check both values.
    Before your MODIFY statement, you should simply change the AllowCALChange value to true.
    if (not Rec.AllowCALChange) then
        if (RunTrigger) then
            exit;
    
    Rec.AllowCALChange := false;
    ...
    

    I don't understand why you would want to restrict changes done through the regular UI, but this workaround should get you your desired result.
  • vaprogvaprog Member Posts: 1,144
    You should make the page(s) Editable=FALSE instead.

    You could also monitor all field's OnValidate trigger (Table) and check CurrFieldNo there.
  • jordi79jordi79 Member Posts: 277
    I used CurrentClientType = BACKGROUND instead. The purpose of the customisation was to integrate NAV vendors so that they are managed externally. And since the integration was done via JobQueue, this solution worked for me.
Sign In or Register to comment.