You need to sign in to do that
Don't have an account?
learn1.3947400898749973E12
create a button to update a check box and button should work for both Classic and lightning
I need to create a button that should be update the checkbox and the button should be visible based on a field value. I created the JS button but it didnt work in Lightning. I am new to lightning, Can anyone help me to handle this scenario
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var myquery = "SELECT Id,Hidden_Checkbox__c FROM SBQQ__Quote__c WHERE Id = '{!SBQQ__Quote__c.Id}' limit 1";
result = sforce.connection.query(myquery);
records = result.getArray("records");
var myOpp = records[0];
var updateOpp = new Array();
var myValRev = myOpp.Hidden_Checkbox__c;
if(myValRev == 'true'){
myOpp.Hidden_Checkbox__c=false;
}
else
{
myOpp.Hidden_Checkbox__c=true;
}
updateOpp.push(myOpp);
result = sforce.connection.update(updateOpp);
if(result[0].getBoolean("success")){
window.location = "/" + "{!SBQQ__Quote__c.Id}";
}else{
alert('Could not Export : '+result);
}
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var myquery = "SELECT Id,Hidden_Checkbox__c FROM SBQQ__Quote__c WHERE Id = '{!SBQQ__Quote__c.Id}' limit 1";
result = sforce.connection.query(myquery);
records = result.getArray("records");
var myOpp = records[0];
var updateOpp = new Array();
var myValRev = myOpp.Hidden_Checkbox__c;
if(myValRev == 'true'){
myOpp.Hidden_Checkbox__c=false;
}
else
{
myOpp.Hidden_Checkbox__c=true;
}
updateOpp.push(myOpp);
result = sforce.connection.update(updateOpp);
if(result[0].getBoolean("success")){
window.location = "/" + "{!SBQQ__Quote__c.Id}";
}else{
alert('Could not Export : '+result);
}
Greetings to you!
For lightning, create a custom quick action of update record type and then set the checkbox field value to true in the predefined values section. Add the action to the layout.
Now once you click on the action button, the checkbox value will be updated and the process will be triggered.
Or you can create a lightning component with a button and place it on a page through lightning app builder.
Component:
Controller:
Apex:
For classic, JavaScript button will work fine.
Also, please refer to the below links which might help you further with the above requirement.
https://developingflow.com/2015/03/16/update-a-record-through-a-button-and-salesforce-flow/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thanks for your update. The button opens in a new window when I click the button.