Skip to content

Dynamic Interactions in Salesforce Explained

Dynamic Interactions in Salesforce Explained.

As part of Winter ’22 release Dynamic Interactions was made Generally Available by Salesforce.

Previously, if you wanted to make multiple components on the same app page talk to one another you had to ask a developer to write extensive code.

No more! Dynamic Interactions has come to your rescue. You can accomplish this task by just some point and click tools.

1. What are Dynamic Interactions in Salesforce?

With Dynamic Interactions, an event occurring in one component on a Lightning page, such as the user clicking an item in a list view, can update other components on the page. Dynamic Interactions lets admins create applications with components that communicate and transform based on user interactions.

Dynamic Interactions has four major building blocks:

  1. Event – Anything that can trigger an interaction, such as a mouse click, a button press, or a change in a field’s value.
  2. Interaction – An activity that happens between the source and the target.
  3. Source – The item triggering the event. Currently, only custom Lightning web components are supported as sources.
  4. Target – The item that’s the target of the interaction. Any component on a Lightning page can be a target.

An event occurring in one component (the source) can trigger changes in one or more other components on the page (the targets). A single source can have multiple targets.

To enhance your understanding of Dynamic Interactions, we have created an application which demonstrates the use of DI. 

2. Overview of the Sample Application used in the Article

Forcepective Insurance Company has recently shared the requirement for an open position for a Salesforce Developer and we have received an overwhelming response. However, due to our busy schedules we won’t be able to go through each of them and approve them and send them mails manually. We want to do all of this in a single click.

Dynamic Interactions is here to save the hassle!

Approvals Made Easy is an app which contains an app page containing 3 Components namely Application List, Application Detail, and Contact Detail(Contact Email).

Object: Job_Appliaction__c

Application List: It contains a list of all the job Applications and their status(approved or Not Approved).

Application Detail: It shows the CV of the applicant and an Approve button. On clicking this button the status in the application list changes from not Approved to Approved. The approve Button is present only for applications which are not approved.

Contact Detail: It contains the Email Id of the applicant and a button Send mail appears for the applications which have been approved.

3. Time to Experience the Dynamic Interactions Magic!

We have created a package containing the Approval Made Easy application and its components 

Note: These components in the package were just created for the demo and may not be production ready.

4. Let’s Get Started!

  • After Installing the package , Click on the App Launcher and Open Approval Made Easy Application
  • This is an app which contains an app page containing all the 3 components available in the package.

Dynamic Interactions in Action
  • The applicationList Component contains an event definition in its meta.xml file 
Dynamic Interaction Meta File 1
  • The recId Property contains the record id of the applications in the list View. This event is fired from the applicationList Component. Therefore, the applicationList component becomes the source.
Dynamic Interactions Event
  • Click on Edit Page, select the applicationList component and navigate to the Interactions tab.
Dynamic Interactions App Builder
  • To establish a connection between applicationList and applicationDetail components , Click on Add Interactions and add the following details(if not already added).
Interaction Config 1
  • To establish a connection between applicationList and contactEmail components , Click on Add Interactions and add the following details(if not already added).
Interaction Config 2
  • This ensures that the source component (Application List) can talk to target components (Application Detail and Contact Detail) and share the correct record Ids of the job applications. The {!} ensures you enter dynamic properties.
  • That’s it! You can save the changes and test the application.

5. Things to remember while using Dynamic Interactions

  • Dynamic Interactions are only supported in App Pages.
  • The source component must be LWC ,but Aura or LWC can be the target component.
  • Isn’t supported in the Salesforce mobile App.
  • You can use expressions only for properties of type String,Integer, and Boolean.
  • Event is the only context supported for expressions in interactions.
  • You can’t set a target property value as an array or list of values, such as a multi-select picklist.
  • Only String and Rich Text type properties can use expressions to define their values.
  • When a dependent property is auto populated with a value based on a selection you made or a value you entered in another property, the auto populated value isn’t saved unless you “touch” the dependent property field by clicking into it or tabbing to it.

Dynamic Interaction is an amazing add on to the greatness that Salesforce provides. It makes Event propagation simpler with few lines of code. 

Did you get a chance to experience this enriched Awesomeness? If Not, get started with installing the package provided in this article.

Let us know your thoughts about Dynamic Interactions in the comments!

6. Additional Details

About the Author

Riya Sawa

Riya Sawa

Riya is 4x Certified Salesforce Admin, Developer and Consultant. When she is not blazing trails on Trailhead, you can find her reading books, painting, gardening, and hiking.


2 thoughts on “Dynamic Interactions in Salesforce Explained”

Please Leave a Comment