0

Background: I am trying to redirect a user from an external site to my salesforce visualforce page with a GET query param as part of the URL. (This is part of a managed package)

I want that parameter to be passed to my apex code so that I can do stuff with it on the server-side (after validating that it is what I expect, etc. of course).

What I have tried so far:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_System_PageReference_getParameters.htm

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_currentpage.htm

Unfortunately, I haven't been able to see the get param in my apex code using either of those strategies.

I am concerned that there may have been a change to how query params work in the Summer '19 update (https://releasenotes.docs.salesforce.com/en-us/spring19/release-notes/rn_forcecom_general_namespace_prefix_cruc_reminder.htm) so that they don't get passed through, even if I am using a namespaced get param. (I tried both the c__ and the <my managed package namespace>__, but other than continuing to see the param in the address bar, it hasn't helped.

In particular, when doing a sanity check, even though I can see the get param in the address bar after visiting the page, I noticed that I can't get the get parameter to be available to javascript running in the VF page:

When I go to https://<scratch org namespace>.lightning.force.com/lightning/n/MyCustomPage?mypackagenamespace__parameter=helloworld

I would expect to be able to see the mypackagenamespace__parameter param get printed to the console using this javascript:

<script>
   window.onload = function(){
            console.log(window.location.search);
   }
</script>

But instead, I am seeing a completely different URL and set of SFDC parameters:

?sfdc.tabName=<SFDC id>&vfRetURLInSFX=%2Fhome%2Fhome.jsp&ltn_app_id=<SFDC id>&nonce=<nonce code>&sfdcIFrameOrigin=https://<scratch org namespace>.lightning.force.com&tour=&isdtp=p1&sfdcIFrameHost=web&clc=0

Now for my question:

Does anyone know why this is happening and how I can make it so that my GET param can be appropriately passed through to make it to my server-side code?


Update: I just tried to go to https://<scratch org namespace>.visualforce.com/apex/MyCustomPage?mypackagenamespace__parameter=helloworld instead of the lightning/n/MyCustomPage version and it worked.

Is there a way to make it work with the original URL, or do I just need to make sure to adjust the URL target to use the apex/MyCustomPage format?

2
  • 3
    Related question: as far as I know, you cannot pass parameters via the Lightning /n/ named tab URL.
    – David Reed
    Jan 2, 2020 at 19:22
  • @DavidReed Could you add an answer that matches your comment so that I can pick that? I think you are right. Jan 6, 2020 at 17:02

1 Answer 1

1

My understanding, based on a previous question and implementation I did, is that one cannot pass parameters to a Visualforce page when the page is targeted via a Lightning Named Tab URL (i.e., under /n/).

Instead, you do have to use the apex/MyCustomPage URL, which does allow parameters to reach the Visualforce page controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.