Blog

Salesforce URL Hacks (Spring 20)

Innovalleyworks - Salesforce URL Hacks (Spring 20)
Salesforce URL Hacks for pre populating the field values in standard lightning page layouts.

What was exist?

In Salesforce classic we have an option to pre-populate the data via custom detail page buttons by URL Hacks.
But this feature was stopped in the lightning. Hence Salesforce launched an option called custom Actions.

Restrictions on Custom Actions Layout:

This custom action has certain limitations like the number of fields can be placed in the layout.
Also this custom action does not work for Case object where you can place the button only on the chatter publisher.

How can we achieve it?

In the spring 20 release again we can use the same URL hacks for prepopulate the data in lightning.

Now you could again use the URL hacks to pre-populate the field values in lighting using the following steps.

Create Detail Page Button On Case Object and prepopulate some of the fields from Case to a custom object(Enquiry__C)
/lightning/o/Enquiry__c/new?defaultFieldValues=Case__c={!Case.Id},Account__c={!Case.AccountId},Site__c={!Case.Site__c}
You can construct the URL in the Detail page button, I am trying to set the Case field values to the Enquiry child object. Want to prepopulate Case Number, Account Name, Site Name in the fields.
Example:
Assigned field name = Assigned field value
Site__c={!Case.Site__c}

But there is a small issue when we pre populate the lookup fields. If the look field contains the values on the parent object this will work perfectly. But if there is blank value in the parent field this will throw an error also the condition testing part is not working on the Detail page button
Work Around: So create a formula field and construct the URL based on the condition and assign the value to this detail page button and works perfectly without any issues.

Example formula field to construct the URL:

‘Case__c=’+Id+ IF( AccountId != null, ‘,Account__c=’+AccountId,”) + IF( Site__c != null, ‘,Site__c=’+ Site__c,”)

Finally the output is :