{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
if({!Opportunity.Book_Now__c} == false)
{
var c = new sforce.SObject("Opportunity");
c.id = "{!Opportunity.Id}";
c.Book_Now__c = true;
result = sforce.connection.update([c]);
if ( result[0].getBoolean( "success" ) )
{
window.location.reload();
}
else
{
alert( result[0].errors.message);
}
}
else
{
alert("Already True");
}
I need to make this available in Lightning. I saw an old post that said to but in
/{!Opportunity.Id}/e?retURL=/{!Opportunity.Id}&00N34000006DfS8=1&save=1
but when I do that and test it, it brings up a compact layout. I just want to be able to click a button and have that action check a box.
How do I do that?
3 answers
Hi LG,
For this, you have the following options available.
#.1Create Quick Actions which updates the current record by setting the Value to true for your checkbox. Disadvantage of this solution is that it will always update record even it the checkbox is already true.
#2. Launch a flow with a url button. In the flow you have to check if checkbox was already checked or not, If not then only update the record.
#3. Creating Custom code either with lightning component or visualforce page.
I would suggest you #2.
Best Regards
Nisar Ahmed