web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How use Xrm.Page.data.process.setActiveStage(stageId, callbackFunction);? And dudes.

(0) ShareShare
ReportReport
Posted on by

Hello everybody!!

I have a question with this method: 

Xrm.Page.data.process.setActiveStage(stageId, callbackFunction);
I'm triying use it, but I can't used it (I don't know where is my mistake).
Notes:
*I use console.log to know the StagesId, it don't be in the final code.
*I don't know if it's okay, but I made a select box field (estado) that will be in
the Stages (1-2-3-4-5), my idea is that the user will select a status process (estado)
like "Hold On"(Frozen Process with little waiting time),"Postergado"(Frozen Process with high waiting time)
or "Lost Opportunity" (Maybe a competidor won or the client abbandond the proyect) and with
this status, the process move to the stage (Hold On --> Stage 8- Hold On).

-If you considering that use a select box tell me the reason. I only have 2 day with Js
I don't know much.
-For my asking, would you explain who use the method? And what is the callbackFunction,
I didn't get any example/information about it in Internet.
-Sorry for my english in sometimes and Thanks for your Time! ^^,

I left my actual code:

function Move(){
	// Definir Booleano respecto a moveToNext
	var moveToNext = true;
	// Para adquirir información del Stage activo del proceso.
	var activeStage = Xrm.Page.data.process.getActiveStage();
	// Para adquirir la colección de Stages del proceso.
	var activePathCollection = Xrm.Page.data.process.getActivePath();
	// Para adquirir el Stage actual
	var StageSelect = Xrm.Page.data.process.getSelectedStage();
	//Para adquirir el nombre del Stage actual
	var StageName = StageSelect.getName();
	
	// Para adquirir el ID de la Stage actual
	var idstages = StageSelect.getId();
	//	Xrm.Page.data.process.setActiveStage(stageId, callbackFunction);
	
	//----------------------Revisar el Salto Que NO SALTA! Move not ev al 1:1--------------------------------
	// -------- En un momento solo dio error de "CallbackFunction" Undefined-------
	//Creamos el Obj para el Estado
	var estadObj = Xrm.Page.getAttribute("mk_estado_op").getOption();
	//Creamos la Var que almacena los estados posibles
	var estado = Xrm.Page.getAttribute("mk_estado_op").getOptions();
	// Crearemos la Var que registra el Estado seleccionado
	var estados = Xrm.Page.getAttribute("mk_estado_op").getSelectedOption();
	// Vamos adquirir el Texto del estado
	var estadotxt = Xrm.Page.getAttribute("mk_estado_op").getText();
	// Condicionamos el estado
	if (estadotxt === "Hold On"){
		//Según me informaron en el foro, se usa esta: Xrm.Page.data.process.setActiveStage(stageId, callbackFunction);
	 Xrm.Page.data.process.setActiveStage("757da4d7-bc58-c063-2ede-1291171cbc6d", function)}
		//-----------------------------------------------------------------------------
	
	// Condicionemos el proceso	 para fase 1-5
	if (StageName === "Etapa 1- Identificar Prospecto"){
		console.log(idstages);
		var backstage = Xrm.Page.data.process.getSelectedStage();
		var manic = Xrm.Page.getAttribute("mk_manact_inicial").getValue();
		var reuini = Xrm.Page.getAttribute("mk_reunion_inicial").getValue();
		if((manic == false) ||(reuini == false) ){
			moveToNext = false;
		}
		if (moveToNext) {
	    //Move to the next stage
	    Xrm.Page.data.process.moveNext();
	}
	}
	if (StageName === "Etapa 2- Reconocer Necesidades"){
		console.log(idstages);
		var backstage = Xrm.Page.data.process.getSelectedStage();
		var manac =  Xrm.Page.getAttribute("mk_manact_actualizado").getValue();
		var whois =  Xrm.Page.getAttribute("mk_who_is_who").getValue();
		var cust =  Xrm.Page.getAttribute("mk_customer_need").getValue();
		var spin =  Xrm.Page.getAttribute("mk_spin").getValue();
		if (( manac == false) || (whois == null) || (cust == null) || (spin == false)){
			moveToNext=false;
	}
	if (moveToNext) {
	    //Move to the next stage
	    Xrm.Page.data.process.moveNext();
	}	
	}
	if (StageName === "Etapa 3- Evaluar Alternativa"){
		console.log(idstages);
		var backstage = Xrm.Page.data.process.getSelectedStage();
		var ppremi =  Xrm.Page.getAttribute("mk_propuesta_premilinar").getValue();
		var vulne =  Xrm.Page.getAttribute("mk_vulnerabilidad").getValue();
		var currents =  Xrm.Page.getAttribute("mk_current_situation").getValue();
		if ((ppremi == false) || (vulne == false) || ( currents == null)){	moveToNext=false;
	}
	if (moveToNext) {
	    //Move to the next stage
	    Xrm.Page.data.process.moveNext();
	}	
	}
	if (StageName === "Etapa 4- Resolución De Aprensiones"){
		console.log(idstages);
		var backstage = Xrm.Page.data.process.getSelectedStage();
		var iapre =  Xrm.Page.getAttribute("mk_iaprensiones").getValue();
		var fechaec =  Xrm.Page.getAttribute("mk_estimated_close_date").getValue();
		var rapre =  Xrm.Page.getAttribute("mk_raprensiones").getValue();
		if ((rapre == false) || (fechaec == null) || ( iapre == null)){	moveToNext=false;
	}
	if (moveToNext) {
	    //Move to the next stage
	    Xrm.Page.data.process.moveNext();
	}	
	}
	if (StageName === "Etapa 5- Negociación"){
		console.log(idstages);
		var backstage = Xrm.Page.data.process.getSelectedStage();
		var pfa =  Xrm.Page.getAttribute("mk_propuestafinaladjuntado").getValue();
		if ((pfa == false) ){	moveToNext=false;
	}
	if (moveToNext) {
	    //Move to the next stage
	    Xrm.Page.data.process.moveNext();
	}	
	}
	if (StageName === "Etapa 7- Perdido"){
		console.log(idstages);}
	if (StageName === "Etapa 8- Hold On"){
		console.log(idstages);}
	if (StageName === "Etapa 9- Postergado"){
		console.log(idstages);}
	}

*This post is locked for comments

I have the same question (0)
  • Clem Profile Picture
    2,541 on at

    On the line : Xrm.Page.data.process.setActiveStage("757da4d7-bc58-c063-2ede-1291171cbc6d", function)

    you could at least use something like :

    Xrm.Page.data.process.setActiveStage("757da4d7-bc58-c063-2ede-1291171cbc6d", function(data){
        alert(data);
    });


    this will provides you some additional data regarding the success or error.

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at

    Hi,  In your script i can't see callbackFunction defined anywhere.

    callbackFunction method is used to get the actual result you want after the process is implemented.

    Please have a look on following links:

    msdn.microsoft.com/.../dn481607.aspx

    community.dynamics.com/.../crm-2015-javascript-code-example-2-save-a-form-asynchronously-with-call-back-function

    Hope this helps:)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans