Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello there!

I've a dude about with the status notification: "dirtyForm".

I've look that it's when the Stage didn't save the changed and got a move (Previuos or Next).

I've got that error when I used the function: 

Xrm.Page.data.process.setActiveStage("8fe9029a-e925-4224-97eb-f6603847a95b", function (estado) { Xrm.Utility.alertDialog(estado, null);})

It's a example of my CodeList. It's for move to the first Stage when the user select the option for that.

When I saved (my script is in OnSaved Event). So I must used 3 click for active it: *1° Clik Saved Form *2° Click Show "dirtyForm" *3° Click Show "Success".

Before my dude, I'll explain my idea and code (I've tried make some arrows xD):

                                               ------Stage7: Close------

                                                              ^^^^

                                                              ///////

                     --------Stage8: On Hold -----------    ----Stage7: Close---

                 ////////                                   ^^^^                  ^^^^

                 vvvvvv                                    ///////                  ///////

[[[[[  Stage1:Start ---> Stage2--->Stage3--->Stage4-->Stage5   ]]]]]-->Stage6: Win

Like you can see, I've a process with five stages, where:

*If the process is Oks, we can keep moving until winning the lead.

*If the process isn't Oks (We Lose), we can skip to Stage7:Close (by branch).

*If the process got trouble, we can Skip to Stage8:On Hold. And:

-If the trouble was fixed, we must come back to Stage1:Start

-If the truble got worse, we must close the lead (Go Stage7:Close).

And there are some information of the "building of my code":

*To make Stages7-8 I've used Branch Stages by Dynamic 2016 options.

*Any Stage (1-5) has their activation branch var (on_hold1 , on_hold2,...) to move to their branch stages with similar name (We have 5 "Stage8: On Hold").

*Stage8 has their activation var to move to Stage1 or Stage7.

So for example, If the process get problem in Stage2 and in the next week it fixed:

Stage1: Oks -->Stage2: Troubles / "on_hold2":Yes -->Stage8: Fixed / "fixed":Yes -->Stage1

My following dudes are:

1) It's a normal? (Get dirtyForm and afther success)

2) If the problem is that the form don't saved. How can I solved it? (I tried used saved function before the setActiveStage and nothing happened).

3) In the example. How can I delete the values in the vars "on_hold2" and "fixed" when the process came back to Stage1? (I've tried used setValue and nothing happened).

4) In any case...it's oks move to the first stage with this?? or there we have a special function for it?

---------

For your time Thanks you and renember please, I'm new in JavaScript, I've tried this script with much help in the forum, so I don't will undestad your answer if you told me:

"read the library in microsoft"(I've already read it and it's bad for consulting xD!). "use ajax and done"(???).

"use the real function to saved" (and don't give the code...).

"Bro I don't know, but maybe it's magic" (be serius please).

"Use the special addition in the ............and .........."(much expert information that assume that I know JavaScript and CRM2016 like if I born with it xD [Not details for new users :c]).

"Use the function "jumping_stage1" and done" (Where you get that?? I don't see any information of it...)

"You'll try debbuging and solved by yourself" (Yeah...I'll do but I don't have Visual Studio License for install a debugger :c [If you know any trial that I can use, It'll help ^^]).

PD: Yes, I know that I sound very stricted... but in previous post I've got some answered like that.

PD2: If you need all the Code, I'll pasted the link of a post where I pust the full code.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Bro maybe you are sleep now, but I must say...........I LOVE YOU!!!! I was finding information with "branching criteria meet" and loocked that in all infos (bad to be honest) they called the process Obj, so I tried it and work!!!!.

    :D now my code auto-mode to branch stages.

    I think that how I never make that the code know the actual process (the first time it has that but I deleted that jejeje, and in the first time I didn't has the branchs stages yet), it never move to that stages because he "never exist".

    ;D You can keep sleep my master!

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Hi,

    would you mind to wait (it is midnight and i have to sleep).

    I will try my best to provide the code tomorrow. :)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    How is it?

    In the CRM I've the follow branching criteria (I think) <If OnHold is True> and the branch Stage.

    In the script I've used the var that has OnHold ("mk_on_hold") and nothing success.

    I need use a special calling??

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Hi,

    Yes it is possible.You have to make sure the branching criteria is met, then only call the moveNext().

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Ops! XD It work, hahaha thanks with that bro. ;D I now don't give double msn [dirty-success] ; I forgot write ";" in the sentence of my code (in the script) kkkk.

    Can you solve this dude?

    With my full code I can auto-move from Stage1 to Stage2 (They are lineal process). But I want auto-move from Stage1 to Branch1 (Branch1 is a branch Stage).

    Example:

    If all field are true, my "mk_on_hold" will be false and my process get S1->S2.

    -------------------------------

    if (StageName === "Etapa 1- Identificar Prospecto"){

    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 y VISTA

    Xrm.Page.data.process.moveNext(function (status)

    {

    console.log(status);

    console.log(Xrm.Page.ui.getFormType());

    if (Xrm.Page.ui.getFormType() == 1 && status == "invalid"){

    Xrm.Page.data.entity.save().then(successCallback, errorCallback);

    function successCallback(){

    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());

    }

    function errorCallback()

    {

    console.log("error");

    }

    }

    else if (status == "success")

    {

    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());}});}}

    -----------------------------

    If the fields not are completed at all (the last vars) and the user see that the process is stoped, he will indicated and IT must move to that branch.

    var onHold = Xrm.page.getAttribute("mk_on_hold").getValue();

    if (onHold == true){

    Xrm.Page.data.process.moveNext(........ [All the logic pasted before]

    }

    with this, the process never move to the branch stage :S, Do you know if it's possible to auto-move to a branch? or it's a sweet dream.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Hi

    another format issue, haha.

    Xrm.Page.getAttribute("mk_reanudar_abandonar_2").setSubmitMode("always");

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    XD I go write with the names:

    if (StageName == "Etapa 8"){

    var reabdos = Xrm.Page.getAttribute("mk_reanudar_abandonar_2").getValue();

    }

    if (reabdos == 850000000){

    Xrm.Page.GetAttribute("mk_reanudar_abandonar_2").setSubmitMode("always");

    Xrm.Page.data.process.setActiveStage(Id1, function(estado){Xrm.Utility.alertDialog(estado,null);});

    }

    I'm triying that when reados get value (850000000), the process came back to Stage1, but when I tried, It give 2 dialog [dirtyform- success] (And yes... it dont saved and I don't know why, but later it saved and get success).

    The guy told me that I must use the setSubmidMode("always")

    I've tried it already and I keep get this "error" [dirty-success].

    PD: I don't know XD, but if I use the var in setSubmitMode it gave me the error of method, but with the string, the error disapear and keep with my old problem XD.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Hi,

    from the code you shared, it seems the format is wrong

    var attribute = Xrm.Page.getAttribute("XXXX").getValue();

    if (attribute == Value)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Bro a dude. I have it

    var attribute = Xrm.Page.getAttribute("XXXX").getValue();

    if (Attribute = Value){

    Xrm.Page.getAttribute(Attribute).setSubmitMode("always");

    Xrm.Page.data.process.setActiveStage(ID, Callback);

    }

    But when I'm using it, this give me "The Object don't use this attribute or the method "setSubmitMode".

    Do you know why it happened?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Any can solved me theses dudes? (dirtyForm, setActiveStage, Saved, setValue Explain)

    Oh I've never seen that! Thanks man! I go check where I must put 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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans