SBX - Search With Button

SBX - Forum Post Title

setActiveStage

Microsoft Dynamics CRM Forum

CrmMouss asked a question on 18 May 2018 10:28 AM
My Badges

Question Status

Suggested Answer

hi ,

I have BPF with  5  stages

i want to set active the last stage but i get (Invalid Error)

there is my script

Xrm.Page.data.process.setActiveStage(GUID, function(result) {
if(result == "success") {
    alert("Success");
} else {
    alert("Invalid");
}
});

Thank you

Reply
CrmMouss responded on 18 May 2018 10:42 AM
My Badges

for information this code is called in  onload  action

Reply
Aric Levin responded on 18 May 2018 10:57 AM
Suggested Answer

What is the exact error that you are getting and from what stage are you trying to set the Active Stage?

I think that if you want to move to the last stage, you need to call the setActiveStages for each stage that you are skipping.

As an alternative you can also use Dynamics 365 Workflow Tools to set the process stage to the final stage.

github.com/.../Dynamics-365-Workflow-Tools

Hope this helps.

Reply
CrmMouss responded on 18 May 2018 11:03 AM
My Badges

Thank you for reply

I have my process with five stages

Stage1 -- stage 2 -- stage 3 -- stage 4 -- stage 5

when i load form i want set active the stage 5

but the method Xrm.Page.data.process.setActiveStage  retun Invalid result

Reply
Aric Levin responded on 18 May 2018 11:07 AM

What I said is that you might have to set all the previous stages before your set stage 5.

There are conditions that will not allow you to go from Stage 1 to stage 5 without completing the previous stages.

Reply
Goutam Das responded on 18 May 2018 11:07 AM
Suggested Answer

Hi,

Few things need to check before doing setActiveStage -

Make sure you are doing Active stage only completed stage and the selected stage must be the active stage.

As far as I know Invalid error occur due to either a stageid which you are providing is not exist and may be  active stage has not been selected, or the record is not yet saved.

Hope this helps.

Reply
CrmMouss responded on 18 May 2018 11:17 AM
My Badges

Hi aric

the other stages are completed , so i don't know whey i get error

because when the process was in stage 3 and i set Stage 1 or Stage 2 by js  it works

Reply
CrmMouss responded on 18 May 2018 11:21 AM
My Badges

hi Goutam thank you for reply

my stageid exists , but i don't understand (may be  active stage has not been selected)

what is the difference between active stage and selected stage )?

Reply
Goutam Das responded on 18 May 2018 11:26 AM
Suggested Answer

Hi ,

When process was in stage 3 you can do this as the process is already completed  and saved , try to save all completed stages and then make setActiveStage.

Reply
CrmMouss responded on 18 May 2018 11:29 AM
My Badges

How can i save all completed stages ?

Reply
Goutam Das responded on 18 May 2018 11:32 AM
Suggested Answer

Hello ,

Please check below reference  - this will help you  to understand completely about the method setActiveStage .

msdn.microsoft.com/.../dn817878.aspx

Reply
Aric Levin responded on 18 May 2018 10:57 AM
Suggested Answer

What is the exact error that you are getting and from what stage are you trying to set the Active Stage?

I think that if you want to move to the last stage, you need to call the setActiveStages for each stage that you are skipping.

As an alternative you can also use Dynamics 365 Workflow Tools to set the process stage to the final stage.

github.com/.../Dynamics-365-Workflow-Tools

Hope this helps.

Reply
Goutam Das responded on 18 May 2018 11:07 AM
Suggested Answer

Hi,

Few things need to check before doing setActiveStage -

Make sure you are doing Active stage only completed stage and the selected stage must be the active stage.

As far as I know Invalid error occur due to either a stageid which you are providing is not exist and may be  active stage has not been selected, or the record is not yet saved.

Hope this helps.

Reply
Goutam Das responded on 18 May 2018 11:26 AM
Suggested Answer

Hi ,

When process was in stage 3 you can do this as the process is already completed  and saved , try to save all completed stages and then make setActiveStage.

Reply
Goutam Das responded on 18 May 2018 11:32 AM
Suggested Answer

Hello ,

Please check below reference  - this will help you  to understand completely about the method setActiveStage .

msdn.microsoft.com/.../dn817878.aspx

Reply

SBX - Two Col Forum

SBX - Migrated JS