TransWikia.com

How to capture URL parameters

Salesforce Asked by devforce on November 12, 2020

I have used Community builder to build ‘tab’ and mapped it to VF page checkorder but when I try to load https://domain-url/conveyance/s/checkorder?id=a2O21000000aU52 ,I am unable to capture id parameter value.

Now, the reason behind this is checkorder page becomes iframe and doesn’t contain id parameter. So, my question here is: How Can I capture ID value from the URL before it becomes iframe?

One Answer

If you want to use JQuery then you have to write your function to get the URL parameter into VF page like:

function getParameterByName(name, url) {
    name = name.replace(/[[]]/g, "\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/+/g, " "));
}

Or if you want to get the URL parameter into controller class then you can use below:

String recordId = ApexPages.currentPage().getParameters().get('id');

Answered by Gourav Verma on November 12, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP