function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
enossirenossir 

opening a VF page from a lightning component and passing a record Id

Current we have a VF page that works fine in lightning experience, and we'll want to continue using it. The problem is initializing the page requires a JS button such as this. 

 
var w = window;
var html_doc = w.document.getElementsByTagName('head')[0]; 
var js = w.document.createElement('script'); 
  js.setAttribute('type','text/javascript'); 
  js.setAttribute('src','/support/console/31.0/integration.js'); 

html_doc.appendChild(js); 

var url = '/apex/TicketResolve?id={!Case.Id}&source=Product_Build__c&type=ticket';
             js.onload= function() { 
                    if(w.sforce.console.isInConsole() == false) { w.open(url,'_blank'); } 
                              else { 
                    navigateToUrl(url,'DETAIL','{!Case.CaseNumber}');
}

Now i'm trying to create a lightning component (initialized from a quick action) that does the same job. 

obviously the comp will need something like 
 
<aura:component implements="force:lightningQuickAction" implements='force:hasRecordId'>

To be honest i'm not sure what i'll have to add to the component section, it just needs to grab the current record id and then initaite the JS controller which is this. 
 
({
    goToUrl : function(component, event, helper) {

        var urlEvent = $A.get("e.force:navigateToURL");
        var recordId= component.get("v.recordId");

        urlEvent.setParams({
             "url": "/apex/TicketResolve?id=" + recordId + 
            "&source=SVC_Product_Build__c&type=ticket", 
            "isredirect": "true"
        });
        urlEvent.fire();
    }
$A.enqueueAction(action);
    })

Now above is just a guess of what i'll need; i wasn't sure if i need the "redirect" : "true" section...and i've seen people use ' instead of ". Also I'm wondering if the urlEvent.setParams will work.

Now does $A.enqueueAction(action); need to be there? the JS isnt calling on the server from what i understand...? It's not calling on apex methods?  i know the component.get function on the record Id is pulling from the record but isn't it getting that from the component portion of the aura bundle(which gets itself from the server) ...
 
Saravanan RajarajanSaravanan Rajarajan
Hi Please  Use it retrieve the store recordId Like this.


({
    goToUrl : function(component, event, helper) {

      var action = component.get("c.<Ur Apex Code Method Name>");
        action.setParams({
            "Qutid" : component.get("v.recordId")    // Use it retrieve the store recordId;
        });
action.setCallback(this, function(response){
        var urlEvent = $A.get("e.force:navigateToURL");
        var recordId= component.get("v.recordId");

        urlEvent.setParams({
             "url": "/apex/TicketResolve?id=" + recordId + 
            "&source=SVC_Product_Build__c&type=ticket", 
            "isredirect": "true"
        });
        urlEvent.fire();
    
});
$A.enqueueAction(action);
}
    })