[SalesForce] e.force:navigateToURL

I want to send list of selected record Id's from a Lightning component to a visual force page.

Is there any limit on length of url parameters when I use e.force:navigateToURL event and append record id's the url, for this purpose?

Thank you.

Best Answer

1.I would recommend you to look at window,postmessage method, it is the recommend secure way to communicate between lightning components and visualforce pages.

https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html

2) IF you decide to use navigatetoURL and pass it as url params as you guessed, you will have to deal with url limitations, as far as i can know the url limit is set by browsers https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

2) Also lightning will base64encode your params and append it as a #XXXXXXX value in your url. Anyone who wants to know what is going behind scenes, all they have to do is to use a base64decoder (https://www.base64decode.org/) and convert the # to reveal all the param data.

eG:

({
    gotoURL : function (component, event, helper) {
        var urlEvent = $A.get("e.force:navigateToURL");
        var str= 'abscdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd';
        urlEvent.setParams({
            "url": "https://praowin-dev-ed--c.gus.visual.force.com/apex/testpage?relatedId="+str
        });
        urlEvent.fire();
    }
})

Resulting url from the above component:

https://praowin-dev-ed.lightning.force.com/one/one.app#eyJjb21wb25lbnREZWYiOiJvbmU6YWxvaGFQYWdlIiwiYXR0cmlidXRlcyI6eyJhZGRyZXNzIjoiaHR0cHM6Ly9wcmFvd2luLWRldi1lZC0tYy5ndXMudmlzdWFsLmZvcmNlLmNvbS9hcGV4L3Rlc3RwYWdlP3JlbGF0ZWRJZD1hYnNjZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGQifX0%3D

enter image description here

Related Topic