0

I have a lookup field in my opportunity object. It is not available in page layout for some user, but they should able to clear this value of this field.

I have created a custom button with javascript, but it not working as expected. Kindly help me. CDH_Account__c - lookup field.

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var opptyObj = new sforce.SObject("Opportunity");

opptyObj.Id = '{!Opportunity.Id}';
opptyObj.CDH_Account__c = "";

var result = sforce.connection.update([opptyObj]);

if (result[0].success=='false') {
     alert(result[0].errors.message);
} else {
     location.reload(true);
}
0

You can solve this declaratively by using a process builder and a checkbox field. Set the process so that when a user checks the checkbox field the process builder will fire. The Process builder runs in system mode so it can take action on records that the user typically is unable to and can update the field on their behalf.

If you need to use a button, you can use a visual flow along with the above to kick off the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.