function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Peter Russell 9Peter Russell 9 

How to create custom opportunity button

Hi,

I am trying to create a button (I think it needs to be java) to clear specific fields in an opportunity. 

There is a date and text field that I would like to be able to clear at the push of a button, does anyone know how to go about this or know of the jscript to use?

Please note I am a complete novice when it comes to coding!

Thanks :)
Pete 
Om PrakashOm Prakash
Hello Peter,
Bellow piece of JavaScript code will work for you.
{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js")} 
var objOpp = new sforce.SObject("Opportunity"); 
objOpp.id ="{!Opportunity.Id}"; 
objOpp.TextFieldApi__c = " ";
objOpp.DateFieldApi__c = null;
var lstRecords = [];
lstRecords.push(objOpp);
var result = sforce.connection.update(lstRecords);
alert(result);
window.location.reload(); // Refresh the details page to view the changes

Let me know if any query.