Pages

Tuesday, March 13, 2018

Salesforce: Update Parent Record with Action

Use case: the request is to have the ability to update some fields in parent record object (such as Account) from a child record (such as Contact) page.

Before Lightning (read in Classic), you need to write a visualforce page with apex controller, then add the visualforce page into Contact page layout.

In Ligthning Experience, this becomes much simpler with Lightning Page + Lightning Component + Action, it sounds a lot, but actually, it's very simple, just a few clicks without any script involved. Let's get this started:

1. Create Action in Account
Because we are Account from Contact, the Action must be created in Account.
- Navigate to Setup | Object Manager | Account | Buttons, Links, and Actions
- Click New Action button
- Enter as the screenshot below:



2. Set Action Layout
From the action created, click Edit Layout button, remove default fields added, add fields that you would like the user to update, and click Save button. You can set the fields as Read-Only or Required, even they are not in the object itself page layout.



3. Edit Contact Lightning Page
Navigate to  Setup | Object Manager | Contact | Lightning Record Pages
Click the page, then click Edit button.


4. Add Component
From Standard components available in the Component panel at the left, drag Related Records component into Lightning Page.



5. Select the Action
Select component added and change the values, change Lookup Field value from "Use This Contact" to "Account Name", then change Update Action with action just created. See screenshot below



6. Showtime
Now, open a contact and check the component added. If you have the permission to update Account, you will be able to update Account fields from here.






No comments:

Post a Comment

Page-level ad