How to configure communication between Forms
Last updated
Last updated
Forms can be used in combination. You can add the form to another one as a nested form or place 2 forms on the same lightning page.
Forms can communicate with each other by passing parameters or using actions. You can call your form action from any other form.
In example bellow you will be able to refresh values in the picklist on the Nested form when the input picklist value is changed on the Parent form.
Create a new form.
Add an Input Picklist. Change "Title" and "Name".
Check "Dynamic options".
Specify value as "{$FormParameters.cities}".
Picklist options will be populated with parameters passed to the Nested form from Parent form.
Create new form.
Add Virtual Input Picklist. Change "Title" and "Name" fields.
Add 2 options: "USA", "France".
Add Variable "cities" with blank value. It will be passed to the Nested Form. While Country is not selected Cities will be blank.
Add Nested Form to the Parent form, select the form you created on the previous step.
Pass parameter cities.
Add "Update Value" Action to update "cities" Variable when "Countries" picklist value is changed.
"value" is the parameter which will be passed to this action from "Countries" picklist "OnChange" Action.
Add "Refresh" action to refresh the Nested Form when "Countries" picklist value is changed.
Add OnChange Actions to the Countries picklist.
Action 1 will be triggered when USA is selected
Action 2 will be triggered when France is selected
So when user select one of the countries, onChange action will update cities value and will refresh the nested form passing new options to cities picklist.
In example bellow you will be able to refresh values in the list on the Parent form when the input picklist value is changed on the Nested form. This option can also be implemented on 2 different forms which are not connected with each other, i.e. they are not parent-nested but are 2 independent forms on the lightning page.
Create Nested Form.
Add a Virtual Picklist to it (14).
Add some options (15).
Create Parent Form.
Add the Nested Form (16) you have created to it.
Add a List of Accounts (17) to the Form.
Add a Variable to define conditions for the List of Accounts.
Set variable default value to an empty string ('').
Define Condition for the List.
This will filter Accounts based on the value, specified in the "accountSource" Variable.
On the Parent Form we need to create an Action which will update Account Source Variable, it will accept accountSource as a Parameter (19):
After the Variable is updated we need to refresh Accounts list, so that new value for Condition applied. Create an action for it:
Now we need to add an action to the Nested Form which will call these Parent Form actions we have just added:
Create an Action.
Select the Type: Form Api.
Select Form Action Type: Execute Form Actions.
Select the checkbox "All Forms" (20) - it will allow to work with any action on any form.
Select the Parent Form we've created.
Add Actions. In the Action drop-down we now have all actions from the Parent form.
Select "Update Accounts Source" and "Refresh Accounts" Actions.
Action "Update Accounts Source" will accept as a Parameter "accountSource" (21):
Action "Update Accounts Source" will accept as a Parameter "accountSource" (21):
Add an onChange event for the "Account Source" picklist:
Event calls the action we have just created passing the selected value:
Now each time when user selects Account source parent form actions will be triggered and list will be updated.