One Button/ Link that works in both Classic and Lightning

Yes, it works.

I have recently posted this article related to the lightning predefault link from Spring '20.

Using such things will take the users to Lightning, but we might have some old-timers who still wanna stick to classic, so this case they might see two buttons/ two links one for classic and one for lightning, sometimes it gets uglier....


Just when you think that is all bad, you might end up adding or changing field definition or record type...!!! As Homer Says D'Oh!

If only you knew how to put all these together, right?!?

Turned out we could!

We can use URL hacks in Lightning now, and we now know if the user is on classic or lightning using $User.UIThemeDisplayed in your button/ link editor.

The only complexity here is, using them both in one big formula... we have to  be really careful about the merge-field expressions...

Following the use case from the previous post, Lightning URL Hacks/ Predefault fields in lightning

We dont really have to keep one button for classic and another for lightning, take this example...
{!IF(
/*Checks which UI user is on */
$User.UIThemeDisplayed =='Theme4d',
/*TRUE:Make the URL for LTNG UI*/
URLFOR('/lightning/o/Vehicle__c/new?useRecordTypeCheck=true&defaultFieldValues=Opportunity__c='+Opportunity.Id+',Contact_Name__c='+Opportunity.AccountId__c+'&backgroundContext=%2Flightning%2Fr%2FOpportunity%2F'+Opportunity.Id+'%2Fview'),
/*FALSE: Make the URL for Classic*/
URLFOR('/setup/ui/recordtypeselect.jsp?ent=a01&retURL=%2F'+opportunity.Id+'&save_new_url=%2Fa01%2Fe%3FCF00NK0000002B5m1%3D'+Opportunity.Name+'%26CFCF00NK0000002B5m1_lkid%3D'+Opportunity.Id+'%26CFCF00NK0000002B7H1%3D'+Opportunity.AccountName__c+'%26CFCF00NK0000002B7H1_lkid%3D'+Opportunity.AccountId__c+'%26retURL%3D%252F'+Opportunity.Id+'&type=cla')
)}

I kept the parameters for record type selection as well as retURL in both lightning and Classic.
Please notice the usage of "backgroundContext" and "useRecordTypeCheck=true" in LTNG  and "recordtypeselect.jsp?ent=a01" in Classic.

This works in list buttons, related list buttons and also custom links.



Finally,  This looks easy if you know the fundamental thing about formula here, everything is wrapped inside an IF() condition and we used one expression. So did you notice there is only one exclamation mark '!'  in the formula...

Use it with caution.

HTH
Prabhan

Comments

  1. Gambling in the US: The 9 best casinos, ranked - Dr.
    The 9 best casinos, 군산 출장안마 ranked · 1. Hollywood 전라북도 출장샵 Casino Perryville, OK · 2. Hollywood Casino Marysville, OK · 광주 출장샵 3. Tropicana 통영 출장안마 Atlantic City, 익산 출장마사지 OK · 4. Golden Nugget Atlantic

    ReplyDelete
  2. One Button/ Link That Works In Both Classic And Lightning >>>>> Download Now

    >>>>> Download Full

    One Button/ Link That Works In Both Classic And Lightning >>>>> Download LINK

    >>>>> Download Now

    One Button/ Link That Works In Both Classic And Lightning >>>>> Download Full

    >>>>> Download LINK ya

    ReplyDelete

Post a Comment

Popular posts from this blog

Passing URL parameters to controller in Lightning components/ AURA

Lightning spinner inside Button

Nested AURA:IFs in Lightning Components Salesforce