Wednesday, 2 August 2017

Redirect to a URL from a lightning component in Salesforce

To Navigate to a detail page use below code,

navigateToRecord : function (component, event, helper) {
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
  "recordId": "00QB0000000ybNX"
});
  navEvt.fire();
}



To Navigate to a URL, use below code,

({

   navigate : function(component, event, helper) {
    //Find the text value of the component with aura:id set to "address"
    var address = '/s/detail/'+recordId;
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url": address,
      "isredirect" :false
    });
    urlEvent.fire();
  }

})

No comments:

Post a Comment