Create Object-Specific Quick Actions
Learning Objectives
After completing this unit, you'll be able to:
- Create an object-specific action.
- Add an action to an object’s page layout.
- Test an object-specific action in the Salesforce mobile app.
Quick Actions: The Sequel
At this point, you can feel pretty proud of your mobile customization skills. You’re an expert at creating global actions, and you’re ready to face your next challenge: object-specific actions. Never fear—the process of creating an object-specific action is very similar to creating a global action, so this unit will be a breeze.
Object-Specific Actions in the Salesforce Mobile App
To kick off our discussion of object-specific actions, let’s talk about what makes them different than global actions.
- Object-specific actions can update records.
- Object-specific actions can create records that are automatically associated with related information. For example, a user could initiate an action that simultaneously creates a contact and associates it with an account.
There’s one more big difference. To expose object-specific actions in the mobile app, you don’t add them to the global publisher layout like we did in the last unit. Instead, you make them available to users by editing the object’s page layout. You’ll see all these differences in action—pun intended!—as you walk through the steps in this unit.
Let’s check out D’Angelo’s use case for object-specific actions so we can start building some cool stuff.
The DreamHouse Scenario
When D’Angelo did his ride-alongs with a few DreamHouse Realty brokers, he noticed they spent a lot of time showing properties to prospective buyers and managing their schedule. He wants to give the brokers a fast way to schedule a new showing in the Salesforce mobile app, so he’ll create an action that will appear on the contact detail page.
Lay the Groundwork
To simulate the DreamHouse use case, you need to build a few things in your own org first. Now, now...no grumbling. We promise it’ll be worth it. You’ll get to witness the power of object-specific actions in a real-world scenario, plus you can practice your wicked platform-building skills.
Create the Property Custom Object
It would be hard for brokers to schedule a new showing without being able to associate it with a specific property. How would they know which home to show? So let’s create a custom object called Property.
If you created the Property object in your org when you earned the Data Modeling badge on Trailhead, you can skip this step, but you'll need to make sure that the Allow Activities option is selected.
- From the Object Manager, select Create | Custom Object.
- In the Label field, enter
Property
.
- In the Plural Label field, enter
Properties
.
- In the Optional Features section, select Allow Activities.
- Click Save.
Now we’ll create a custom tab for the Property object.
- Enter
Tab
in the Quick Find box, then select Tabs.
- In the Custom Object Tabs list, click New.
- In the Object dropdown list, select Property.
- For the Tab Style, select Real Estate Sign.
- Click Next. Accept the defaults, then click Next again.
- Click Save.
Customize the Event Object for Showings
You’re a savvy admin, so you probably guessed that a showing is a type of event. But D’Angelo doesn’t want to use standard events for showings because users need to enter extra information about them, like the related property and the buyer’s feedback.
The best way to handle this customization challenge is with a new event record type that has its own page layout. Let’s create a page layout specifically for showings, then create an event record type and link it to the new page layout.
- From the Object Manager, enter
Event
in the Quick Find box, then select Event.
- From the Event object management settings, go to Page Layouts and click New.
- Select Event Layout from the Existing Page Layout dropdown list.
- In the Page Layout Name field, enter
Showing Layout
.
- Click Save.
- From the Event object management settings, go to Record Types and click New.
- Enter
Showing
in both the Record Type Label and Record Type Name fields.
- Click Next.
- Select Showing Layout in the Apply one layout to all profiles dropdown list.
This layout only applies to the Showing record type. The standard event record type continues to use the Event Layout.
- Click Save.
Create a Lookup Field for Showings
Hang in there! This is the last step. We just need to create a custom Property field so brokers can associate showings with properties. We do that with a lookup from the activities object to the property object.
- From the Object Manager, enter
Activity
in the Quick Find box, then select Activity.
- From the Activity object management settings, go to Fields and Relationships and click New.
- Select Lookup Relationship, then click Next.
- In the Related To dropdown list, select Property, then click Next.
- Enter
Property
in the Field Name and Field Label fields, then click Next.
- Select the Visible checkbox so the field is available to all profiles, then click Next.
- Deselect the Event Layout and Task Layout. We only want this field to appear on the Showing Layout.
- Click Next.
- Enter
Showings
in the Related List Label field.
- Click Save.
Create an Object-Specific Action
Whew, you made it through your homework assignment. Now that all the pieces are in place, you can enjoy your reward—helping D’Angelo create an awesome object-specific action.
Here’s what we need to do. D’Angelo wants to create a New Showing quick action and make it available on the contact detail page in the Salesforce mobile app. That way, when a broker schedules a new showing, it’s automatically associated with the record for the prospective buyer. So in this step, we create an object-specific action for contacts.
- From the Object Manager, enter
Contact
in the Quick Find box, then select Contact.
- From the Contact object management settings, go to Buttons, Links, and Actions and click New Action.
- Verify that the action type is Create a Record. Actions can do more than just create records. To learn more about the other options, read the Object-Specific Actions article in Salesforce Help.
- In the Target Object dropdown list, select Event.
- In the Record Type dropdown, click Showing.
- Enter
New Showing
in the Label field.
- Click Save.
- In the layout editor, remove the following fields: Related To, Assigned To, and Name.
- Add the Property field to the layout and make it required. You can double-click the field to edit its settings.
- Remove any extra spaces and arrange the fields in a single column.
- Click Save.
- Click Yes to acknowledge the warning. Even though it’s required, it’s fine to remove the Assigned To field from the layout because it defaults to the current user.
Note: Don’t remove a required field from the layout unless:
- The field has a default value.
- You specify a predefined field value for the action.
- The field already contains data. For example, if the action updates a record, the user entered the required information when they initially created the record.
- Now let’s save the brokers some time by prepopulating the Subject field. In the Predefined Values related list, click New.
- In the Field Name dropdown list, select Subject.
- In the Specify New Field Value field, enter
"Showing"
. Be sure to put the quotation marks around the word.
- Click Save.
Add an Action to an Object’s Page Layout
We’re in the home stretch! Now we just need to add the new action to the page layout for contacts. Then it will be available in the action bar in the mobile app when a broker is viewing a prospective buyer’s record. (Don’t forget—when you create an object-specific action, it belongs on the page layout for that object.)
- From the Object Manager, enter
Contact
in the Quick Find box, then select Contact.
- From the Contact object management settings, go to Page Layouts and click Contact Layout.
- In the Salesforce Mobile and Lightning Experience Actions, if you see a link to override the predefined actions, click the link to override.
- Select Mobile & Lightning Actions in the palette, then drag the New Showing quick action into the mobile section. Make sure it’s the first item.
- Reorganize the actions so the most frequently used ones are first, and remove any unnecessary actions.
- Click Save.
And we’re done! Now DreamHouse brokers can quickly schedule a new showing with a prospective buyer.
Test the Action in the Salesforce Mobile App
Here comes the really satisfying part—it’s time to test your beautiful new action in the mobile app. So fire up Salesforce on your device, and let’s walk through this use case together.
- Tap to open the navigation menu. If you’re already in the Sales Lightning app, pull down to refresh the navigation menu. If you’re not in the Sales Lightning app, tap App Launcher, then tap the Sales Lightning app to open it.
- Let’s first create a new property so we can associate it with a showing. In the navigation menu, tap Properties. If you don’t see Properties in the navigation menu, tap All Items to find it in alphabetical order.
- Tap New.
- For the property name, enter a street address.
- Fill out other required fields, if any, then tap Save. Now we can look up a prospective buyer and schedule a showing with them.
- Open the navigation menu, then tap Contacts.
- Select the contact you created in the previous unit, or create a new one.
- Pull down to refresh the action bar.
- Tap New Showing.
- Complete the fields.
Tip: Dictation is much faster than typing. When you get to the Description field, activate voice input by selecting the Microphone icon on the keyboard. This native OS feature can be a real time-saver for busy mobile users, so be sure to tell them about it.
- Tap Save.
- Let’s go back to the Property record so you can see that the new event appears in the Showings related list. Open the navigation menu, tap Properties, then select the property you just created.
- Tap Related.
- Tap Showings to see all the showings scheduled for that property.
Pretty cool, huh? You’re really getting the hang of this mobile stuff. (Feel free to pat yourself on the back...you deserve it.)
After racking up your points, head over to the next unit where you learn how to streamline your record detail pages in the Salesforce mobile app using compact layouts.
Resources