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.
0
Answers
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.
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.
You could also monitor all field's OnValidate trigger (Table) and check CurrFieldNo there.