You need to sign in to do that
Don't have an account?
Aruna
how to replace window.open(vfpage url?id='xxxx') on custom button in lighting custom button
Hello everyone,
now we are moving from classic to lighting I need to convert all the javascript button to lighting.
We have a custom button which has below url on it
window.open('/apex/vfpagename?id=xxxxx');
how do I replace window.open in lighting and I want the button to work both in lighting and in classic.
Can any please help me on this if any sample code will be appreciated.
Thank you,
Aruna.
now we are moving from classic to lighting I need to convert all the javascript button to lighting.
We have a custom button which has below url on it
window.open('/apex/vfpagename?id=xxxxx');
how do I replace window.open in lighting and I want the button to work both in lighting and in classic.
Can any please help me on this if any sample code will be appreciated.
Thank you,
Aruna.
Create a global action and call below lighting component.
Lighting Component
<aura:component controller="ProductInUseCntrl2" Implements="flexipage:availableForAllPageTypes,force:lightningQuickAction,force:hasRecordId" access="global" >
<!--<lightning:button label="Open in new Window" onclick="{!c.openActionWindow}"/>-->
<aura:handler name="init" value="{!this}" action="{!c.openActionWindow}"/>
</aura:component>
Java script controller
({
openActionWindow : function(component, event, helper) {
// var accId=component.get("v.recordId");
window.open( "/apex/vfpageName?id=" + component.get("v.recordId"));
//window.close();
$A.get("e.force:closeQuickAction").fire();
}
})
The only problem with this is unable to close the global action window
can anyone, please correct me my code to close quick action window.
All Answers
Refer this links
https://nebulaconsulting.co.uk/insights/lightning-experience-configuration-converter/
https://developer.salesforce.com/blogs/2018/06/convert-javascript-buttons-to-lightning-friendly-alternatives-with-the-lightning-experience-configuration-converter.html
https://github.com/developerforce/LEXComponentsBundle/blob/master/force-app/main/default/aura/redirectConditionalUrl/redirectConditionalUrlHelper.js
I did try your solution it's not working getting below error message
Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.
Action failed: forceChatter:lightningComponent$controller$doInit [Right-hand side of 'instanceof' is not an object]
quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent
this quick action should on the Account object
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
<aura:handler name="init" value="{!this}" action="{!c.navigate}"/>
</aura:component>
({
navigate : function(component, event, helper) {
//Find the text value of the component with aura:id set to "address"
var address = component.find("address").get("v.value");
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({"url":'/apex/productInUse?id=' + component.get("v.recordId")});
urlEvent.fire();
},
})
Create a global action and call below lighting component.
Lighting Component
<aura:component controller="ProductInUseCntrl2" Implements="flexipage:availableForAllPageTypes,force:lightningQuickAction,force:hasRecordId" access="global" >
<!--<lightning:button label="Open in new Window" onclick="{!c.openActionWindow}"/>-->
<aura:handler name="init" value="{!this}" action="{!c.openActionWindow}"/>
</aura:component>
Java script controller
({
openActionWindow : function(component, event, helper) {
// var accId=component.get("v.recordId");
window.open( "/apex/vfpageName?id=" + component.get("v.recordId"));
//window.close();
$A.get("e.force:closeQuickAction").fire();
}
})
The only problem with this is unable to close the global action window
can anyone, please correct me my code to close quick action window.