1

We are looking into greater view customization for our standard object detail pages. For instance we'd like the user to be able to decide if they'd like the on page popup form, or the full page form of a new visit object. The popup form is called through a Lightning Component Button. The full page is called through a Custom Visualforce Button. I'd like to make a button that can check to see if the user has opted for one view or the other, and then open that component. I have this formula

{!IF(
    $Permission.Can_See_Custom_View,

    URLFOR('/apex/'+$Setup.AdditionalSettings__c.Namespace__c+'__MLogVisit?id='+Contact.Id+'/e'),

     URLFOR('/lightning/cmp/c__NewVisitQuickActionFromLayout?c__recordId='+Contact.Id+'/e'))
}}

Neither works. The Lightning one gives "This page isn't available in Salesforce Lightning Experience or mobile app." And the other opens into Salesforce Classic and says that the data is not available.

Is this even possible to do, or am I just wonky on the syntax? Any help is super appreciated!

1 Answer 1

2

First of all, /e is only used on Classic URLs for standard record edit pages. For example, to create an Account, use /001/e, and to edit an existing Account, use /001xx0000012345/e.

Second, you're not using URLFOR in the proper manner. It has a particular syntax:

URLFOR(url, recordId, [parameters], [noOverride])

Third, you need to use your namespace if you're using a namespace.

Fourth, there are ways to address a Visualforce page correctly.

As such, the formula should be closer to:

{!IF($Permission.Can_See_Custom_View,
  URLFOR($Page.MLogVisit, Contact.Id),
  URLFOR('/lightning/cmp/c__NewVisitQuickActionFromLayout', null, [c__recordId=Contact.Id])
)}

Though I haven't specifically tried to link to Lightning Component this way, so I'm not 100% on the syntax for that, and it's been a while since I've had to use URLFOR, so the other may be slightly off, too. I'd recommend you double-check the documentation for more information.

2
  • Ohhh I wasn't aware you could just link pages like that, I'll try it out. I saw the URLFOR thing here salesforce.stackexchange.com/questions/322231/… so that's what I was going off of. I'll give it a shot and report back! Commented Dec 3, 2021 at 23:00
  • Ah so unfortunately, as I've set the content source to URL, I can't link the VFPage in the manner given above as the $Page option is not available. Plugging it in just yields a syntax error. The URLFOR for the LC is still giving "This page isn't available in Salesforce Lightning Experience or mobile app." but I think that may have to do more with pathing than anything. Commented Dec 3, 2021 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .