I am storing the public url of a pdf file in a field of a custom object. I am able to successfully retrieve the url. how can I fire the url when a user click a button? Is it possible through JS controller? Thanks in advance for your help.
0
-
Is that lightning component? – Pranay Jaiswal Dec 6 '18 at 15:07
-
yes. I tried doing it in href tag <a href="{!Module.URL__c}" target="_blank">DOWNLOAD </a> but this does not work. Module is the nale of the custom object and URL__C is the field name. – medhavi Dec 6 '18 at 15:10
-
How is this post any different than your previous question? – Adrian Larson♦ Dec 6 '18 at 15:11
0
You can do that using e.force:navigateToURL,
on press of a button fire the below event, it will open that URL
gotoURL : function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": 'fileURL';
});
urlEvent.fire();
}
src: https://developer.salesforce.com/docs/component-library/bundle/force:navigateToURL/documentation
-
Thanks for the reply Pranay. It is wrking when I am assigning a static url but how do I pass the url dynamically in this function? My url is stored in URL__c field of a custom object which I am retrieving in the APEX class. Thanks a lot in advance. – medhavi Dec 6 '18 at 15:22
-
Follow this, this will tell u how to get that URL from APex, developer.salesforce.com/docs/atlas.en-us.lightning.meta/… Once you got the URL you can redirect – Pranay Jaiswal Dec 6 '18 at 15:23