Actionable URLs!

Sayantani Mitra
CRM Analytics
Published in
4 min readJul 5, 2020

Einstein Analytics Actions is a super useful feature that allows users to take appropriate actions on the data they are seeing. We can open and edit records, log a new case, create a new record, post comments, etc. We can also create our own Actions in Salesforce and use them in the Actions feature of Einstein Analytics! To learn more about actions, click here.

There is one part of Actions that has been a question I have heard from friends and users of Einstein Analytics alike — “Can we open URLs without going to the records?” YES!! Absolutely and it is fairly simple to achieve.

How??

We will use our usual dataset for this blog, the taxi data. In the taxi dataset that exists in Salesforce, we create a new field of type URL called “Website” and add the Taxi Affiliation Websites to them. We can use any field even if it is in a csv file as long as it contains the URL field. We see that some of these Affiliations don’t have a website and hence they are marked as “N/A”.

Taxi Affiliation Websites

URLs have a common starting point: https://<rest of the URL> or http://<rest of the URL>. The difference between the two protocols is that https is secured while http isn’t. In other words, https is http with encryption. More on this can be found here.

When we open the dataset in Analytics Studio, it shows us how the URL has to be formatted to open.

http://www.google.com?q={{row.AccountNumber}}

And the URL in this box has to start with http:// or https://. This means that we need to strip the Website field off https:// or http://. This can be done using a compute expression in the dataflow. And adding the formula below:

case when 'Website__c' matches "https://" then substr('Website__c', 9, 250) when 'Website__c' matches "http://" then substr('Website__c', 8, 250) else 'Website__c' end

Breaking this further:

  • We have 3 variations for the field, viz., https://, http://, N/A. Thus we use a case statement to address all 3 cases.
  • In the case statement, we use matches instead of the exact string because there can be many URLs and not all of them need to be written separately. All we want is to remove the protocol (https://, http://) part from the field and we are using exactly that as the criteria.
  • The format for using a substr or substring (part of a string) is substr(<fieldName>, <start character>, <end character>).
  • In this case, https:// has 8 characters and hence we want the substring to start from the 9th character. Similarly, http:// has 7 characters and hence the substring starts from the 8th character. We then add 250 as the end value with the assumption that an URL will not be longer than that!
Compute Expression to Shorten URL

Steps:

  • Open the dataflow to which we want to add the Compute Expression.
  • In the digest node check if the URL field exists, if not add it and propagate.
  • Next, create a Compute Expression node and add a new field (Website_short). Use this new node as your left or right source instead of the digest node or any other node as the case may be.
  • Update the dataflow and run!

Now all that remains is adding ACTIONS!!

Refresh Analytics Studio. Find the dataset and click edit. Then click on the gear icon on the top right which says “Configure Actions”. Find the field Website__c. Now, use Taxi_Affiliation__c in the Record Id field. Then under “Configure Actions” select Open Salesforce Record and select URL from the dropdown. In the URL box write the following:

https://{{row.aff.Website_short}}

This represents a row followed by the API Name of the newly created formula field which is this case is aff.Website_short.

Actions on URL

Notes and Caveats:

  • It is best to add the compute expression as soon as you can, maybe right after the digest node, if you have all the fields you need for the formula or after you have joined it to another digest node so that you have all the required fields.
  • In cases where there can be multiple rows with the same URL, choose a Record Id that will be unique to the data else you will see a whole gamut of records showing up on screen to choose from. Say, you have a URL on the opportunity object that is shared by 5 records, use Account Id as your Record Id assuming that the URLs will be unique to the Accounts, meaning, multiple Accounts can't share the same URL.

--

--