Search code examples
salesforcesalesforce-lightning

Why does URLFOR() function for a list view button function differently between sandboxes?


I am using the URLFOR() function in a list view button to re-direct to a lightning component that implements the lightning:isUrlAddressable interface. As part of the URLFOR() function, I am passing in some URL parameters in the third argument, one being a merge field and the other a static string value:

{!URLFOR("lightning/cmp/c__MyComponent", null, [id=Related_Object__c.Id,sObjectName="My_SObject_Name__c"])}

This is working correctly in our DEV sandbox (API version 45.0) but the same configuration does not work in our QA sandbox (API version 46.0).

When clicking the list view button in our QA sandbox, I notice that the URL parameters are not being populated at all for "id" and "sObjectName". I confirmed this by logging the value of the PageReference variable in the Lightning component as well.

Are there any differences between the API versions or other issues that might cause this behavior?


Solution

  • Per the Summer '19 Release Notes:

    Add a Namespace Prefix to Query Parameters and pageReference.state Properties was a critical update in Winter ’19 and is enforced for the Summer ’19 release. This critical update resolves naming conflicts for query parameters between package components.
    

    In this way, the above query parameters need to at a minimum use the default namespace "c__":

    {!URLFOR("lightning/cmp/c__MyComponent", null, [c__id=Related_Object__c.Id,c__sObjectName="My_SObject_Name__c"])}
    

    Documentation: https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_general_namespace_prefix_cruc.htm