Skip to main content
All CollectionsAsite AppBuilderAppBuilder Sample Scripts
Launch New Form while viewing an existing Form
Launch New Form while viewing an existing Form

This is an AppBuilder Sample Script.

Updated over a week ago

Below is a an example to help you understand how you can configure a form design in a way that when a user views a form of a particular type, they can create a new form of similar type along-with prepopulated data based on original form and related attachments or associations as applicable.

Suppose there is a form type called 'Site Information' where we are capturing a title, location details and task details using different fields in 'Create View' as follows:

  • Title - A 'text box' field with field name 'ORI_FORMTITLE'.

  • Location - A 'text box' field with field name 'Task_Location'.

  • Reference - A 'text box' field with field name 'Task_Reference'.

  • Date - A 'date picker' field with field name 'Task_Date'.

  • Task Details - A 'text area' field with field name 'Task_Details'.

Here, user can copy the above form details while viewing an existing 'Site Information' form to a new form of same type (i.e. Site Information) and also associate the form that is being viewed with the new form as a reference. Below are the steps to be followed:

1. From the 'Create View', go to the copy dropdown at top right and select 'Copy All'.

2. Create a new view called 'Created View' and then go to the paste dropdown at top right and select 'Paste as Read-only'.

3. Add a new 'Button' field with field name 'Copy_and_Associate' and label it as 'Copy and Associate with a New Task'. The new view should then look as follows:

Below are the steps to use the drag and drop code editor to define a condition upon the 'onClick' event of 'Copy_and_Associate' button field, in 'Created View':

1. Here, we have used the custom function 'Launch Form - Target Setup'. In the corresponding dropdown, we have selected 'Current Project' and form name as 'Site Information'.

2. Next, we have used the custom function 'Launch Form Field Mapping'. In the corresponding dropdown, we have set the source and target fields for mapping for each of the available fields separately based on their field name.

It is necessary to use identical values as 'Field Name' and 'Data Field Name' especially for fields within a repeating table or entire repeating table when configuring such scripts in your form design.

3. Additionally, a checkbox option called 'Associate Source Form' is selected which means we are also associating the source form with the new form getting created.

4. Once done, click 'OK' (at bottom right) to save the changes and exit the code editor, then save / publish the form design as needed. Once the form design is published and executed, the changes will be applicable for the new forms created under the related form type.

5. While viewing the form, user can click on the button named 'Copy and Associate with a New Task'. It would launch a new form with the data auto-populated from previous form along-with attachments or associations as per the selected option in form design.


Next Collection: Project Forms


Did this answer your question?