In Dynamics NAV 2017, Microsoft has made it possible to validate the base code without changing the code objects for the following objects and their associated tirgger events:
- Table Object
- OnAfterDeleteEvent
- OnInsertEvent
- OnAfterModifyEvent
- OnAfterRenameEvent
- OnAfterValidateEvent
- OnBeforeDeleteEvent
- OnBeforeInsertEvent
- OnBeforeModifyEvent
- OnBeforeRenameEvent
- OnBeforeValidateEvent
- Page Object
- OnAfterActionEvent
- OnAfterGetCurrRecordEvent
- OnAfterGetRecordEvent
- OnAfterValidateEvent
- OnBeforeActionEvent
- OnBeforeValidateEvent
- OnClosePageEvent
- OnDeleteRecordEvent
- OnInsertRecordEvent
- OnModifyRecordEvent
- OnNewRecordEvent
- OnOpenPageEvent
- OnQueryClosePageEvent
- CodeUnit : For CodeUnits we have individual Event triggers like as follows
- OnAfterAutoFormatTranslate
- OnAfterCaptionClassTranslate
- etc ….
Table Object Events
To use the above Table level trigger events, we have to create a new CodeUnit and the new function, then apply the below properties for that function.
Event => Subscriber
EventPublisherObject => Table Customer
EventFunction => OnBeforeInsertEvent
Finally, the function will look like this:
LOCAL [EventSubscriber] OnBeforeInsertCustomer(VAR Rec : Record Customer;RunTrigger : Boolean)
MESSAGE(‘Before Insert’);
//we can write any validations here
Page Object Events
To use the above Page level trigger events, we have to create new CodeUnit and the new function, then give the below properties for that function.
Event => Subscriber
EventPublisherObject => Page Customer Card
EventFunction => OnAfterValidateEvent
EventPublisherElement => Address (Here we need to give in which field validation you want to write code)
Finally, the function will look like this:
LOCAL [EventSubscriber] OnValidateCustomer(VAR Rec : Record Customer;VAR xRec : Record Customer)
IF xRec.Address <> Rec.Address THEN
ERROR(‘you do not have permision to change Address field’);
CodeUnit Events
To use the above CodeUnit level trigger events, we have to create new CodeUnit and the new function, then give the below properties for that function.
Event => Subscriber
EventPublisherObject => Codeunit ApplicationManagement
EventFunction => OnAfterCaptionClassTranslate
Finally the function will look like this:
LOCAL [EventSubscriber] OnAfterCaptionClassChanged(Language : Integer;CaptionExpression : Text[1024];VAR Caption : Text[1024])
Caption:= CaptionClassTranslate1(Language,CaptionExpression);
NavisionTech is dedicated to providing exceptional support for all of your Microsoft Dynamics needs.
Our Answer Desk is ready to assist you in everything you need. Just send us an email to
support@navisiontech.com and we will be here to answer your questions and provide support when you need it.
Leave A Comment