Table level event handlers - Most commonly used.
Hi All,
In this blog we will learn how to write table level event handlers which are most commonly used.
For all the below examples you need to create a class - Navigate to the table >> Events >> Right click on any events and select "Copy event handler" >> Paste the code in the class and add logic accordingly.
OnInserting - This method will be called during insertion of the record on the table.
[DataEventHandler(tableStr(HcmWorker), DataEventType::Inserting)] public static void HcmWorker_onInserting(Common sender, DataEventArgs e) { HcmWorker worker = sender as HcmWorker; //assign field values }
OnUpdating - This method will be called during the updated of record on the table.
[DataEventHandler(tableStr(HcmWorker), DataEventType::Updating)] public static void HcmWorker_onUpdating(Common sender, DataEventArgs e) { HcmWorker worker = sender as HcmWorker; //assign field values }
OnValidatingWrite - This event handler will be called when save button is clicked on the form to validate records and during insertion of record into a table.
[DataEventHandler(tableStr(HcmWorker), DataEventType::ValidatingWrite)] public static void HcmWorker_onValidatingWrite(Common sender, DataEventArgs e) { HcmWorker worker = sender as HcmWorker; ValidateEventArgs event = e as ValidateEventArgs; boolean ret = event.parmValidateResult(); if(ret) { ret = checkFailed("Error"); event.parmValidateResult(ret); } }
OnValidatingField - This event handler will be called while validating values entered on the field in the form.
[DataEventHandler(tableStr(HcmWorker), DataEventType::ValidatingField)] public static void HcmWorker_onValidatingField(Common sender, DataEventArgs e) { HcmWorker worker = sender as HcmWorker; ValidateFieldEventArgs event = e as ValidateFieldEventArgs; boolean ret =event.parmValidateResult(); if(ret) { switch(event.parmFieldId()) { case fieldNum(HcmWorker, PersonnelNumber): ret = checkFailed("Error"); break; } } event.parmValidateResult(ret); }
OnModififyingField - This event handler will be called while some values are entered on the field in the form.
[DataEventHandler(tableStr(HcmWorker), DataEventType::ModifyingField)] public static void HcmWorker_onModifyingField(Common sender, DataEventArgs e) { HcmWorker worker = sender as HcmWorker; ModifyFieldEventArgs event = e as ModifyFieldEventArgs; switch(event.parmFieldId()) { case fieldNum(HcmWorker, PersonnelNumber): //assign field values. break; } }
Similar to that we have OnInserted, OnUpdated, OnValidatedWrite, OnValidatedField, OnModifiedField. It works similar as it will call after the standard methods are called and it will have same syntax as mentioned above.
Thanks.
*This post is locked for comments