Frequent tasks performed by using form programming are:
- Data Validation.
- Process enhancement and enforcement.
USE FIELD AND FORM EVENTS
Scripts can be added on events like
Whereas, tabs have the event
and IFRAMES have an event called
OnLoad event occurs after the form has loaded. onLoad event is used to prepare the data in the form for use.
OnSave event occurs when a form is saved. It does not correspond to standard HTML OnSubmit event. The OnSave event occurs in the following scenarios:
- When a user clicks on the save button at the bottom right corner of the screen.
- Code executes the Page.data.entity.save method, even when there is no changed data to be saved.
- The user navigates away from the page and there is unsaved data to be saved.
- When auto-save is enabled, 30 seconds after the data has been changed and there is unsaved data on the form.
- Code executes the Page.data.save and even if there is unsaved data on the form.
- Code executes the Page.data.refresh method passing true as the first parameter and there is unsaved data on the form.
OnChange is available for every field. OnChange event requires two conditions to be true:
- The data in the field must change.
- The field must lose focus.
There is an exception to the Two-Option (Boolean) fields. OnChange event occurs immediately when the value is changed without requiring to lose focus.
The OnChange event does not occur if the field is changed programmatically using the setValue method. Instead fireOnChange method can be used in code to trigger OnChange event.
This event occurs when a tab is expanded or collapsed.
This event is important in the case that you want to use script to modify the src property of an IFRAME control.
This event is fired when contents of an IFRAME have completed loading.
- Navigate to Settings > Customizations > Customize the System. Then navigate to Web Resources under Components on the left navigation pane of the Default Solution (Default solution here is used as an example).
- For registering events on OnLoad events, select Form Properties on the form.
- In Form Properties, Select the form libraries that we want to enable on the form level as shown below.
In the above example, a library called ‘new_sampleScript’ has been included. We can now add Event Listeners (which are the functions in that library) that we want to trigger when the library is loaded.
Enter the name of the function you want to trigger on this event.
OnSave event listeners could be bound by simply changing the Event to OnSave as shown below.
For OnChange events, the Field Properties need to be changed. Steps to do so are as follows:
- Navigate to the desired field and select its properties.
- Follow the steps as illustrated for OnSave and OnLoad events above.
Hope this is useful! 🙂