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
Jessica BabeJessica Babe 

Automate Stage Change on Click of Button

We are looking to automate our pipeline to move forward one stage once a sales user clicks a button that takes them to a URL to create their  quote. Is it possible to automate the stage change on the click of the button?

Thanks!

Jessica
AnudeepAnudeep (Salesforce Developers) 
Hi Jessica, 

You can use quick action to update the opportunity stage. See this example. If you want to update the stage based on certain criteria. You should create a lighting component and use it in your quick action or create a javascript button with the login to update the stage like this.
{!requireScript("/soap/ajax/26.0/connection.js")}
var oppId = '{!Contract.OpportunityId__c}';
if(oppId != '' && oppId != null){
	var opp = new sforce.SObject("Opportunity");
	opp.id = '{!Contract.OpportunityId__c}';
	opp.StageName = 'Closed Won';
	result = sforce.connection.update([opp]);
}
else{
	alert("There is no Opportunity to update.");
}

Anudeep
Dushyant SonwarDushyant Sonwar
Jessica,

You can do this by visual flow. Custom Javascript button solutions will not work in lightning.
Try creating a visual flow and let us know if any issue you are getting.