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)

Automatically move the stage of the Business Process Flow

(0) ShareShare
ReportReport
Posted on by

Hi I would like to move the user automatic to the next stage when they have field in all the required step. I know you can use Xrm.Page.data.process.moveNext("", function() {});  to move the user on the next stage. I’m struggling how to write this into JavaScript to check if all steps are complete move on?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nuno Profile Picture
    2,005 on at

    Hi

    First get the steps for the stage:

     

    var stepsCollection = stageObj.getSteps(); // Returns a collection of steps in the stage.

    then you can foreach every step in stepsColletion to get its attribute logical name

     

    var stepAttributeName = stepObj.getAttribute(); // Returns the logical name of the attribute associated to the step.

    and finally check if the attribute contains data

     

    var attributeValue = Xrm.Page.getAttribute(stepAttributeName).getValue(); // Retrieves the data value for an attribute.

     

    If(attributeValue != null) then attribute contains data.

    If the attributes for all steps contain data the move to next stage.

    https://msdn.microsoft.com/en-us/library/6b79eb8c-8293-4d3a-a3a7-ea35157cde37#BKMK_Stage

  • Aldo Macedo Profile Picture
    on at

    Hello PEj,

    You could check this video www.youtube.com/watch Microsoft Dynamics CRM 2015 Business Process Flows New Features.

    How to change process and stage programmatically

    develop1.net/.../How-to-change-process-and-stage-programmatically.aspx

    I hope this information can help you.

    Best regards,

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi PEj,

    This can be done easily by plugin. Try to request the business process and change the process stage accordingly.

    https://deepakexploring.wordpress.com/2013/11/21/programmatically-updating-stagesprocess-for-business-process-flow-in-crm-2013/

    http://www.neudesic.com/blog/business-process-flows-crm-2013/

    http://develop1.net/public/post/How-to-change-process-and-stage-programmatically.aspx

  • PEj Profile Picture
    on at

    Thank-you for your reply, Im getting an error:'stageObj' is undefined. im a newbie to JavaScript so probably missing something.

  • ryguy Profile Picture
    213 on at

    It appears this function only works if the stage you are moving to is connected to the same entity. There is a "cross entity" error that happens otherwise.

    It's actually very annoying that there is no support for scripting cross-entity automation in the process flow...

    As far as checking for all the completed steps, you should evaluate the value of the attributes that those steps are based on. There are plenty of resources on Google for working with form attributes in the XRM client side.

  • Community Member Profile Picture
    on at

    While you can advance via plugin, when checking if required fields are on the form it's usually done with client side scripting to validate then have the user interact before we send it to the platform.

  • Community Member Profile Picture
    on at

    This is a little late :( but for the next guy - you have to get the object first:

    var stageObj = Xrm.Page.data.process.getActiveStage();

  • svignesh Profile Picture
    347 on at

    Hi Micheal,

    Below is my code

    function nextStage(){

    console.log(" case moved to next stage");

    }

    function caseStatusChange(){

    parent.Xrm.Page.data.process.moveNext(nextStage());

    };

    I have attached onchange event to caseStatusChange function

    Its throwing "Refused to set unsafe header" error

    What have i missed?

  • Community Member Profile Picture
    on at

    Hi Vicky,

    No, you need more code, i'm trying to do this javascript too, you can check my code below.

    It won't work if you have a step that doesn't have an attribute, can someone help me with that, for example, on my Case(Incident) the first step has a 'Find Customer' and a 'Has Contact?' field, but when i reach the loop, it won't get the attribute, which will stop the loop and call the if(moveToNext), i have a field below that those 2 that is null, but its not getting validated.

    //Control var (boolean)
    var moveToNext = true;
    
    //gets the stageObject
    var stageObj = Xrm.Page.data.process.getActiveStage();
    
    // Returns a collection of steps in the stage.
    var stepsCollection = stageObj.getSteps();
    
    //loop on the stepsColletion
    for (var i = 0; i < stepsCollection.getLength(); ++i) {
        // Returns the logical name of the attribute associated to the step.
        var stepAttributeName = stepsCollection.get(i).getAttribute();
    
        // Retrieves the data value for an attribute.
        var attributeValue = Xrm.Page.getAttribute(stepAttributeName).getValue();
    
        //if attribute is null set moveToNext to false
        if ((attributeValue == null)||(attributeValue == false)) {
            moveToNext = false;
        }
    }
    
    // If all attributes contain data
    if (moveToNext) {
        //Move to the next stage
        Xrm.Page.data.process.moveNext();
    }


  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Thanks for the answer. What if the attribute contains data how do I prevent it?

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