You need to sign in to do that
Don't have an account?
katy perry
need some urgent help, I am very new to ssalesofrce and I am fully confused with lightning. I have a javascript button to validate some fields and then will allow to take PDF of a visualforce page. Now I need to migrate this JS button to use in Lightning.
need some urgent help,
I am very new to ssalesofrce and I am fully confused with lightning. I have a javascript button to validate some fields and then will allow to take PDF of a visualforce page. Now I need to migrate this JS button to use in Lightning. Please help me with this.
Here is the JS button.
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
var PurchaseOrder = sforce.connection.query("SELECT Id, isPDFGenerated__c, ItemsCount__c, POReleaseDate__c, TotalQuantityPercentage__c FROM PurchaseOrders__c WHERE Id ='{!PurchaseOrders__c.Id}'");
varPOrecords = PurchaseOrder.getArray("records");
if(varPOrecords[0].isPDFGenerated__c == 'true' || varPOrecords[0].isPDFGenerated__c == true){
alert("PDF already generated.\n\nPlease contact your Salesforce Admin to generate again.");
}
else if(varPOrecords[0].ItemsCount__c == 0){
alert("Purchase Order cannot be generated without items.");
}
else if(varPOrecords[0].POReleaseDate__c == null || varPOrecords[0].POReleaseDate__c == ''){
alert("Please enter Release Date.");
}
else if(varPOrecords[0].TotalQuantityPercentage__c != 100){
alert("Delivery Terms Total Quantity cannot be less than 100%");
}
else{
if(confirm("Are you sure, you want to generate Purchase Order PDF?\n\nClick OK or Cancel.")){
var result = sforce.apex.execute("GeneratePOPDF","saveGeneratePdf",{poId:varPOrecords[0].Id});
window.location.reload();
}
}
I am very new to ssalesofrce and I am fully confused with lightning. I have a javascript button to validate some fields and then will allow to take PDF of a visualforce page. Now I need to migrate this JS button to use in Lightning. Please help me with this.
Here is the JS button.
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
var PurchaseOrder = sforce.connection.query("SELECT Id, isPDFGenerated__c, ItemsCount__c, POReleaseDate__c, TotalQuantityPercentage__c FROM PurchaseOrders__c WHERE Id ='{!PurchaseOrders__c.Id}'");
varPOrecords = PurchaseOrder.getArray("records");
if(varPOrecords[0].isPDFGenerated__c == 'true' || varPOrecords[0].isPDFGenerated__c == true){
alert("PDF already generated.\n\nPlease contact your Salesforce Admin to generate again.");
}
else if(varPOrecords[0].ItemsCount__c == 0){
alert("Purchase Order cannot be generated without items.");
}
else if(varPOrecords[0].POReleaseDate__c == null || varPOrecords[0].POReleaseDate__c == ''){
alert("Please enter Release Date.");
}
else if(varPOrecords[0].TotalQuantityPercentage__c != 100){
alert("Delivery Terms Total Quantity cannot be less than 100%");
}
else{
if(confirm("Are you sure, you want to generate Purchase Order PDF?\n\nClick OK or Cancel.")){
var result = sforce.apex.execute("GeneratePOPDF","saveGeneratePdf",{poId:varPOrecords[0].Id});
window.location.reload();
}
}
javaScript button is not support in lightning experience
here is Lightning Alternatives to JavaScript Buttons
https://trailhead.salesforce.com/modules/lex_javascript_button_migration
read this trailhead moudle for understand it
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others , thanks :)
http://sfdcmonkey.com
JavaScript button is not supported in lightning in order to make JavaScript button work in lightning you need to create Quick Action in lightning.
Below is the example for quick create Case with Component and Controller.js code.
Component Code.
JavaScript Code: Also, visit