You need to sign in to do that
Don't have an account?
Yogesh Biyani
Convert Javascript Button to Lightning Component (Step by Step instructions)
We have 3 Javascript buttons which change the record type and reassigns the case to a queue. Here is an example
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.RecordTypeId = '012400000009FQA';
caseObj.OwnerId = '00G40000001dp2s'
var result = sforce.connection.update([caseObj]);
if (result[0].success =='false') {
alert (result[0].errors.message);
} else {
location.reload(true);
}
I am looking for detailed step-by-step instructions/tutorial to convert this to Lightning Component.
Thank you in advance.
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.RecordTypeId = '012400000009FQA';
caseObj.OwnerId = '00G40000001dp2s'
var result = sforce.connection.update([caseObj]);
if (result[0].success =='false') {
alert (result[0].errors.message);
} else {
location.reload(true);
}
I am looking for detailed step-by-step instructions/tutorial to convert this to Lightning Component.
Thank you in advance.
Please refer the below link. It will help you.
https://salesforce.stackexchange.com/questions/184836/help-to-convert-onclick-javascript-button-to-lightning
Regards,
Shalini R
May I suggest you please refer the below link for reference.
- https://developer.salesforce.com/blogs/developer-relations/2016/09/take-the-first-steps-ways-you-can-replace-javascript-buttons.html
hope it helps.Please mark it as best answer if the information is informative.
Thanks
Rahul Kumar
As suggested in StackExchange I have created the following apex page but when I use the button the new page keeps on refreshing. What am I missing?
Thanks in advance for your help.
Yogesh
You have mentioned in the above coding like that location.reload(true) thats the reason page is reloading when update successful.
Please remove that line and mentioned some alert for success message.
Regards,
Shalini R
Thanks for the reply. The flickering has stopped. Is there a way to automatically close the window after it is done?
Yogesh
Please use the below lines, you can able to close window and refresh cash record.
window.opener.location.href = "/{!Case.Id}";
window.self.close();
https://sompaul2012.wordpress.com/2018/04/05/lightning-action-as-a-replacement-of-javascript-button/
Can anyone please help me convert the below javascript code to lightning.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var processStatusValue = "{!Delegation__c.Process_Status__c}";
var delegation = new sforce.SObject("Delegation__c");
delegation.Id = "{!Delegation__c.Id}";
if(processStatusValue=="Requested"){
if(confirm("Are you Sure You Want To Cancel!") == true)
{
delegation.Process_Status__c = "Cancelled";
//alert(delegation.Process_Status__c );
var result = sforce.connection.update([delegation]);
//alert('result'+result);
//alert('result'+result.errors.message);
if(result[0].success == "true"){
location.reload();
}
}
}