Executing after save scripts

It is possible to execute a custom script right after a form item has been saved. This allows you to set custom values of form fields with the possibility to use all the server-defined values as well (e.g. the ID field, which is not available before a new item gets saved into SharePoint).


The example below will show you how to prepare a custom script which will update the "Title" field of an item with a value that will combine two other field values: "ID" and "Date".

Example: for an item with "ID" equal to "1", and "Date" equal to "2018.07.04", the "Title" field will be "1_040718".

Assumptions: the list that the demo is using has an "ID", "Title" and "Date" fields available, and the "Date" field is present in the Form layout.

Step 1 Ensure that the after save script execution is enabled

  1. In Sintel Forms Designer, navigate to the "Settings" section, "After save script" tab and enable the "Enable after save script" option:


Step 2 Type in the custom script

      1. Type in the following code in the "Script" box:
        let date = getDateTime("Date", "ddMMyy")
        let id = getValue("ID");
        setValue("Title", id + "_" + date);


        The code used in the "after save script" should use JavaScript syntax.

      2. Save the designer data.


        When the 'Date' field will be empty the error will occur, however, the form will be saved (only the 'Title' value won't be changed).

 That's it - after a form is saved with a "Date" field provided, the "Title" field will be altered based on the script.

List of available API functions to use in after save script:

Function Description
getValue(fieldName) Returns the value of a field.
getDateTime(fieldName,format) Returns the value of a date/datetime field in the provided format. For a list of possible formats, see here.
setValue(fieldName,value) Sets the value of a field.


Was this article helpful?
0 out of 0 found this helpful