After completing this tutorial, you will be able to:
- Build Custom Objects in Salesforce
- Add Shared Linked Sections to a Form Template that leverages fields on Custom Objects
- Collect and Store Repeating Information
Shared Linked Sections
As outlined in the previous tutorial, Linked Sections can be used to store repeating information and data when it may be unclear how much data needs to be created from a form. We created a linked section that looks up to a standard Salesforce object (Contact), but this can also be done for custom objects. Arabica Coffee has their own custom object where they house data about their coffee products and track inventory. For this tutorial, we will create a Shared Linked Section to hold inventory data about specific Arabica products on the store shelves including their product locations and the amount in stock.
The store rep needs to capture data about the Quantity, Cost, and Shelf Location of each coffee product they encounter in the store. The rep doesn’t know how few or how many products they will encounter and so a Linked Section will help us capture this data and store the known information as records on a related list. Arabica Coffee can then track and report on this in the future. For example, if Arabica Coffee finds that after each visit, Monroe Markets consistently has a low inventory of the same coffee beans, Arabica can assume these beans are selling quickly and can take swift action to ensure this product is always well stocked.
A Shared Linked Section differs slightly from a regular Linked Section in that it allows for pre-populating linked sections on a form using the information in a related list. So in this case, the Arabica Coffee rep would be able to see the coffee inventory for Monroe Markets right when they start a new form and also have the ability to edit that information or create new Linked Sections for new products to capture more data about inventory during their visit.
We’ll start this tutorial by creating the necessary Custom Objects for Arabica Coffee. Begin by logging into your Salesforce Org where you’ve been completing your tutorials.
Create Custom Objects and an Inventory List
- We’ll assume that Arabica Coffee Co. already has a Custom Object called Coffee Products in their Salesforce instance. This is where they keep an updated inventory list of all the coffee products they offer in stores.
- We will learn how to replicate this list later in the tutorial, but we must first create a custom object for the Linked Section that looks up to the form object and contains custom fields to serve as the fields for Quantity, Cost, and Shelf Location.
- In classic: Setup > Create> Objects > New Custom Object
- In LEX: Setup > Object Manager > Create > Custom Object
- In classic: Setup > Create> Objects > New Custom Object
- Enter the name Coffee Products in the label field. Do the same for Plural Label. The Object name will auto-populate. This is where we will keep the inventory lists of all the names of the Coffee Products we offer. When finished click Save & New.
- Click and create another New Custom Object and enter the name Coffee Count in the label field. Do the same for Plural Label. Object name will auto-populate. When finished click Save.
- Under Custom Fields & Relationships (Fields & Relationships in LEX) on the Coffee Count detail page, select New.
- Our first custom field will be a lookup relationship to the Form Object which is necessary for all Linked Sections. Select Data Type = Lookup Relationship, Related to = Form, Field Name = Form, Next > Next > Next > Save & New.
- Our second custom field will be a lookup relationship to our Coffee Products which will pull from our existing coffee inventory list to be available on the form. Select Data Type = Lookup Relationship, Related to = Coffee Products, Field Name = Coffee_Products, Next > Next > Save & New.
- Our third custom field will be a Number field to capture the Quantity of the coffee product on the shelves. Select Data Type = Number, Field Label = Quantity, Next > Next > Save & New.
- Our fourth custom field will be a Currency field to capture the Cost of the coffee product at this store. Select Data Type = Currency, Field Label = Cost, Length = 16, Decimal Places = 2, Next > Next > Save & New.
- Our fifth field will be the Shelf Location which we will offer as a Picklist field on our form with the options of Top Shelves, Middle Shelves, or Bottom Shelves. Select Data Type = Picklist, Field Label = Shelf Location, Values = Enter Values, with each value separated by a new line. Next > Next > Save.
- Create one final field which will be a Lookup Relationship from the Coffee Count Object to the Account Object. This will ensure that inventory data is accessible to users who may be viewing and reporting on the inventory data that is collected. The best way to do so is by having our custom Coffee Count object exist as a Related List on the Account Page Layout.
- Now we need to start populating the inventory Coffee Products inventory list in Salesforce as shown at the beginning of this tutorial. To do this we need to enter setup then navigate to Create > Tabs (User Interface > Tabs in LEX) and click New to create a new custom object tab.
- From the object dropdown select Coffee Products. Then select the Tab Style by clicking the hourglass and selecting Cup. Click Next and Save.
- Now we want to populate our inventory of Coffee Products to replicate the list that was introduced at the beginning of this tutorial. Navigate to the newly created tab which allows us to create new records for each Coffee Products that Arabica Coffee Co. offers.
- On the tab navigation select the dropdown arrow in the top right of the navigation bar and select Coffee Products (App Launcher > Coffee Products in LEX).
- Select New and add in the following Coffee Products to our inventory (be sure to select Save & New after each entry to avoid having to reenter the object):
- Kona Medium Roast
- Sumatran Dark Roast
- Kenyan Fruit Blend
- Colombian Arabica Decaf
- Colombian Arabica
- Arabica Espresso Bean
- Arabica Hazelnut Espresso Blend
- Kenyan Bean
- Kenyan Bean Decaf
- Arabica Breakfast Blend
- Rwandan Dark Roast
Add a Linked Section to your Form Template
- Click the Form Templates tab from the navigation bar and select the Arabica Coffee Store Visit template.
- From the Form Template Detail Page, either delete the associated forms you have in the forms list or select the settings button to Copy for a New Version.
- Click Edit to make changes to your template.
- Drag and Drop a Linked Section into the template builder in between the Store Contact Information and the General Information sections.
- This will open the Linked Section Edit Box. Name your section Inventory Count with 1 column, Linked to the Coffee_Count__c object, with the Object Lookup set to Form__C.
- To make this a Shared Linked Section, switch to the Shared Linked Sections tab and check the checkbox to Share with existing related records.
- You will be prompted to indicate which Form Lookup you wish to share this Linked Section with. In this case, since the Coffee Inventory is related to each account, we will leverage the lookup relationship we created in the Linked Section tutorial between Account and Coffee Count. Set the Form Lookup for Sharing field to disco__Form_Account__c and the Linked Section Lookup for Sharing field to Account__c. You should also choose which order you want these records to show up in. Ordering them by the Coffee Products name makes sense here.
*optional* Remember, we’re using Shared Linked Sections to pre-populate coffee products in a form for any given account that we’re responsible for visiting. However, there might be a reason why we would want to only show certain coffee products for our users. Perhaps we only want to show decaf coffee products, or coffee products within a certain cost window. We can control which related records will pre-populate for our forms users by leveraging the Linked Section Sharing Filters. Indicate that you’d like to display Coffee Products from A-Z, that you only want a maximum of 20 products to populate the form, and that you’d only like to display coffee that is less than $12.00.
- Click Save to continue.
- Drag and Drop a new Question into the Linked Section. Name the Question Product Name with the Field Link Field set to: Coffee Products.
- Repeat step 25 for the following field link questions as well, noting the Question Text and Field Link Field. All other options should remain default.
Question Text Field Link Field Quantity Quantity Cost Cost Shelf Location Shelf Location
- From the template builder screen, your Linked Section should be complete and look like this:
- Preview your template and in the Inventory Count Section, start to type “Kenyan” and see the options available that are looking up to our inventory list.
- Save and close out of your Form Template to return to the Form Template Detail Page.
- From the settings button, Publish your template.
Create a New Form
- Create a New Form from using mock data from your instance. We will demonstrate with the Monroe Markets Account record and Peter Parker’s contact record.
- For the purpose of this form, we will focus on adding a couple of linked sections to test its functionality. The Store Contact Information should prepopulate and enter mock data for the General Information Section.
- Under the Inventory Count Section, click the Add + button.
- Add a Linked Section with the following information:
- Name: Kenyan Bean Decaf
- Quantity: 14
- Cost: 11.99
- Shelf Location: Middle Shelves
- Add another Linked Section with the following information:
- Name: Colombian Arabica
- Quantity: 10
- Cost: 9.99
- Shelf Location: Middle Shelves
- The Arabica Coffee rep could potentially add in as many of these linked sections as necessary to capture all of the products in that particular store.
- Once complete, save the form.
Make Linked Section Data Available on the Account Layout
- From the Form Detail Page, click the Navigate To menu on the left-hand side and navigate to the associated Account record (Monroe Markets).
- Notice that the related list containing your Linked Section data doesn’t automatically appear as a part of the page layout, but you can add it in just a few simple steps. From the right-hand side of the screen, open the arrow that leads to the Quick Access Menu. Select Edit Layout. (in LEX Setup > Object Manager > Account > Page Layouts > Account Layout)
- From the Edit Page Layout screen, you can now drag and drop the Coffee Count related list into the account layout. We then need to customize the list to include the fields that are meaningful from our inventory object. Select the Wrench Icon next to Coffee Count.
- This opens the Related List Properties modal for the Coffee Count Object. From the list of available fields, we want to add in the fields that were meaningful in our linked section, including Coffee Products, Quantity, Cost and Shelf Location. Click and Add each field from the Available Fields list to the Selected Fields List. Click Ok when finished.
- The Related List will now contain the selected fields.
- Save the Account Layout to return to the Monroe Markets Account record.
- You should now see your Coffee Count related list with all of the associated Coffee Products and details. If this exercise was performed correctly, you will see the two Coffee Products appear in this list which we created in the form. Any future Coffee Products captured from this linked section will also appear in this list.Any future Coffee Products captured from this linked section will also appear in this list.
You have now created multiple Custom Objects, an Inventory List, and added a Shared Linked Section to your Form Template to be used to collect repetitive data about Arabica Coffee products in stores.