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

Rule that Updates Opportunity Stage based on Custom Button being clicked

Hey all.


I have a custom butten that resides on my opportunity (renamed 'School Contract').


I want it so that once the custom button is clicked, the 'School Contract' Stage field is updated to 'Contract Completed'.


How can I do this? 


Keep in mind I'm not a very strong coder!!


Thanks a ton!






You can execute a javascript on click of the custom button.


After you create the custom button execute the javascript  like this(change according to your object and fields)



var opp=new sforce.SObject("Opportunity");
var newRecords = [];"{!Opportunity.Id}";
opp.StageName = 'Contract Completed';
var result = sforce.connection.update(newRecords);



Let me know if its working !!


So would this bit of code go on the actual button itself?


Yes. The code goes with the custom button.


For example:
When you create the custom button select
Display Type as "Detail Page Button"
Behaviour as "Execute JavaScript"
Content Source as "OnClick JavaScript"

You can then place this code.

Zachary StevensZachary Stevens
Amena your code worked perfectly on the Opportunity object.  I would like to do the same thing with a custom object of ours called Insruance VOB. How would we go about doing that?