How to Configure Communication Between Forms
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.
An example below illustrates how to configure dependent picklists: an update of the Nested form picklist will be triggered by Parent form picklist.
Nested Form:
- Add a new form.
- Add an Input Picklist.
- Check "Dynamic options".
- Specify value as "{$FormParameters.cities}" (1).
Picklist options will be populated with parameters passed to the nested form from parent form.
Parent Form:
- Add a new form.
- Add Virtual Input Picklist.
- Add 2 options "USA", "France" (2).
- Add Variable "cities" with an empty value. It will be passed to the Nested Form so that Cities picklist will be blank until Country is selected.
- Add Nested Form to the parent, select the form you created on the previous step.
- Pass parameter cities (3).
- Add "Update Value" Action to update "cities" Variable when "Countries" picklist value is changed (4).
"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 (5).
- Add OnChange Actions to the Countries picklist.
- Action 1 will be triggered when USA is selected (6)
- Action 2 will be triggered when France is selected (7)
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 Forms:
- Create Nested Form.
- Add a Virtual Lookup to it.
- Add some options (8).
- Create Parent Form.
- Add the Nested Form you just created.
- Add a List of Accounts to the Form (9).
- Add a Variable to define conditions for the List of Accounts.
- Set variable default value (10) to an empty string ('').
- Define Condition for the List (11).
This will filter Accounts based on the value specified in the "accountSource" Variable
- On the Parent Form we need to create an Action (12) which will update Account Source Variable, it will accept accountSource as a Parameter.
- After the Variable is updated we need to refresh Accounts list, so that new value for Condition applied. Create an action for it (13):
Now we need to add an action to the Nested Form which will call these Parent Form actions we've just added.
- Create an Action
- Select the Type: Form Api
- Select Form Action Type: Execute Form Actions
- Select the checkbox "All Forms" - it allows to work with any action on any form (14).
- Select the Parent Form (15).
- Add Actions. In the Action drop-down we now have all actions from the Parent form.
- Select "Refresh Accounts Source" and "Refresh Accounts" Actions (16).
- Refresh Accounts Source will accept accountSource as a Parameter (17).
- Add an onChange action for the "Account Source" picklist and call the action we've just created passing the value user selected (18).
Now each time when user selects Account source parent form actions will be triggered and list will be updated.
0 Comments
Add your comment