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
jgreene.ax1178jgreene.ax1178 

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!

 

-Jake

AmenaAmena

Hi,

 

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)

 

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


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

 

 

Let me know if its working !!

jgreene.ax1178jgreene.ax1178

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

AmenaAmena

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?