Prefill Toast message using Data Source
The goal of this tutorial is to show how to use Data Source to pre-populate data from any record into any message. The current scenario that we will show we will use a Toast Message, but it could be applied to any of the Advanced Messages.
​
In this scenario we will:
- Create a Toast Message
- Display information from a Related Record into the Message using Data Source
​
Scenario:
We want to display a toast message and display the case number when the case has been escalated with high priority. This message will be into a Contact Record Detail, so the case should belong only to that Contact.
The image below is our end result

First let's create the Data Source to prefill the information into the message.
​
1. Go to EvoluteMessage App in Salesforce App Launcher
2. Go to Data Source Dashboard
3. Click on Add Data Source
4. In Data Source name, give the name: Load Case when is escalated and high Priority
5. In the Object Name field, choose the Case Object
By default, the Case Id will be selected and the filter will be the record id. This is in case we add the message with this data source into a Case Record Detail Page, then this is useful, in our case we will add the message with this data source into a Contact Page, so it is not the Case Record Detail and the Record Id of the Contact won't be in Case Id.
6. Instead of Case Id, let's select the Contact Id.
The first column is the field that we want to filter in this case we want to get any cases by the Contact Id.
6.1. Operator will be Equal
6.2. This scenario we will choose the Record Id for the Value.
This means that, we will get the Record Id from the current page that this data source was loaded, then do a query into the object using the field we have selected. So in our case would be something like, select * from Case where ContactId = ToTheRecordId that we got from the page.
7. Now that we filter only cases for the contact that we are in, we want to filter from those cases only the ones that we want to display, which we said would be all the Cases that has scaled and with Hight Priority.
7.1. Add another line into the filter, to filter the status.
7.2. Choose Field Status, Operator Equal, Escalated
7.3. Add another line into the filter to filter the Priority.
7.4. Choose field Priority, Operator Equal, High.
8. Click on Save
​
By here we are good, we basically built a data source which will load a case record when Status is Equal to Escalated and Priority is equal to High, only for the Contact Id that we are displaying into the Page.
​
This is how our Data Source should looks like:
​

Now that we have our Data Source, is time to setup the message to Prefill.
​
1. Go to Message Dashboard
2. Click on Add New Message
3. Select the Toast Template(Any message would work, even the button though).
4. Give it a Name, like: Show Alert when Case is escalated and high priority.
5. Now into Data Source Prefill Field, select our Data Source called "Load case when is escalated and high priority.
​
Basically till here, we create a message and say to the message that we have a data source to be loaded which we will use to prefill.
​
The message should look like this:

Now that we set the Data Source to be inside of the Message, we will have access to all the fields from that Data Source. Let's add the fields into the message.
​
1. Double click on the Text into the Message
2. Change the message to be: This contact has a case that needs attention. Case ####.
Just paste this message there, the #### will be the place holder for us to add the actual case number.
3. Once you add the text there, now select the #### or click before it, then go to the Dropdown which says "Fields from Data Source", and select the Case Number field and click on the Plus Button.
This step would add the Data Source Id and the Field API name into the message.
​
You should have a message like this image below.

​
4. Click on Done, since we have our case number into the message and we can test to see how it works.
5. Go to the Contact Record Page Detail, add the Advanced Message and select our Message.
6. Our message should be rendering all the time, even though we don't have a case for Prefill.
As you can see in the image below, the case number didn't prefill, this happens because our data source didn't find any case so we didn't prefill at all. We will take care of it to show only when we have a case, but this step is to make sure the message is rendering and you see like the image below.

Now, let's create case with the criteria that we setup the data source.
1. Create a case that has Priority = High and Status = Escalated
2. Reload the Contact Page after that
​
Now we should see our message with the case number.

Related to Prefill that is it, this is how we prefill data from data source into the message, this applies to any message.
​
This scenario still need more work in order to be ready for the user, the steps that we are missing are:
- Show the message only when we actually have a record.
​
We can do that by using the filter and using the same data source that we used for prefill.
​
Let's do on this tutorial the steps to show or hide that.
​
1. Go back to the Message Builder
2. Click on Filter Menu and Click on Add Filter.
3. In Filter Field, choose the Data Source that we have created before, since we want to show the message only when that data source has record.
4. In Data Source Result field, leave the option any of the objects have Records, which mean if the data source return a record we will show the message, otherwise the message will be hidden.
5. Click on Done.
6. Click on Publish.
7. Reload the contact, and the data source should show.
8. Remove the Case or change the Priority or Status to another criteria, and reload the page and the message should be hidden.
​
In our case we use the same data source, but we could use a different criteria to show or hide as well using a different data source. It doesn't need to be in the same data source.
​
I hope that helps, if you have any question please, don't hesitate in send us a message, we will be super happy to know your scenario and help.
​
We have created a video doing something similar for Digital Experience as well and we even added a link into the case number.