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 

converting a JS button to a lightning quick action that initializes a component...how do i get it just to run the JS controller?

Here's the original JS button
 
window.open('https://tool.rss.igt.com/RSSTool/CheckSAPLicense?PERSNO='+'{!$User.EmployeeNumber}');

Here's my lightning controller
 
({
goToUrl : function(component, event, helper) {
    
    var urlEvent = $A.get("e.force:navigateToURL");
    var userId = A.get("$SObjectType.CurrentUser.Id");
    
    urlEvent.setParams({
      "url": "https://tool.rss.igt.com/RSSTool/CheckSAPLicense?PERSNO=" + userId, 
       "isredirect": "true"
    });
    urlEvent.fire();
}
})

Now all i want is a lightning quick action to make ^ above run......so what do i put in my component portion to make that happen...
 
<aura:component implements="force:lightningQuickAction" >
    
    
    <aura:attribute name="onclick" type="Aura.Action" default="{!c.goToUrl}" />    

</aura:component>



Would that work? It's not really doing any server calls...right? From what i understand the JS doing the A.get on the ("$SObjectType.CurrentUser.Id") is getting the current user without having to directly call the server to get the id. Does the client hold onto their user record while using sfdc? could i do Id.EmployeeNumber__c ?
Maharajan CMaharajan C
Hi,

You have to use the init function in aura:handler. Like below.

<aura:component implements="force:lightningQuickAction" >
​    <aura:handler name="init" value="{!this}" action="{!c.goToUrl}"/>​​​​​​
</aura:component>

Thanks.
Maharajan.C