Detect URL Format (Lightning Experience)

Following the announcement that the URL format in lightning experience will change from /one/ we are looking for a way of detecting which format is being used so that we can generate URLs in Apex.

For example, if we were to generate a PDF in Visualforce containing a URL to a lightning page we would like to correct the URL to use the correct format depending on whether the org is using `/one/` or `/lightning`

What does it do?

From the announcement:

It changes the URL format used by Lightning Experience standard apps and the Salesforce mobile app. For example:
Current format: https://<>/one/
New format: https://<>/lightning/o/Account/home

In Summer '18 the new URL format will be enforced, but in Spring '18 it can be enabled for testing via a critical update.

Why do we care?

If the user enabled the critical update themselves we need to be able to make sure that our features still work.

Similarly, if you are dynamically building a URL and use the 'Current format' then Salesforce will redirect the user to the new format, but this degrades the user experience.

How can we manage this change?

In order to offer a seamless user experience we would like the option of detecting which URL format was being used so that we can customise any dynamically created URLs to match the format.

In order to do this we use the following javascript:

If your URL is being generated in Apex, simply pass this value to your apex call and go from there.


Alex said…
This comment has been removed by a blog administrator.

Popular posts from this blog

Handy Scripts for Salesforce Lightning Development

Working with Conditional Attribute Defaults in Lightning