Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

How to set value in custom field on basis of Business process flow stage

Posted on by 45

I have to new custom field called Stage.Now i want to update this field whenever business process flow stage change.for Ex if i move businees process flow stage to  In progres then this value i have to update in custom field called Stage.In Business process flow we have 3 options New,In progress & Close

1325.dynamics.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set value in custom field on basis of Business process flow stage

    Hi Partner,

    Has the problem been solved? Any updates?

    Please click Yes under "Did this answer your question?" to close this thread.

     pastedimage1610505342959v1.png

    Thanks. 

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set value in custom field on basis of Business process flow stage

    Hi Partner,

    You can try to use js code in the onload event, it can directly update field value based on actived stage name.

    In my example, opportunity has a bpf, which named opportunity sales process and has four stage.

     pastedimage1609925622356v1.png

    1.write js code.

     

    function formonload() {
        Xrm.Page.data.process.addOnStageChange(getStage); // Trigger the function when move to next stage.
        getStage();
    }
    function getStage() {
        var activeStage = Xrm.Page.data.process.getActiveStage();
        var stagename = activeStage.getName();
        switch (stagename) {
            case "Qualify":
                Xrm.Page.getAttribute("new_stage1").setValue(0);
                break;
            case "Develop":
                Xrm.Page.getAttribute("new_stage1").setValue(1);
                break;
            case "Propose":
                Xrm.Page.getAttribute("new_stage1").setValue(2);
                break;
            default:
                Xrm.Page.getAttribute("new_stage1").setValue(3);
        }
    }

    2.Go Settings > Customizations > Customize the system > web resource to add it.

    pastedimage1609925558166v6.png

     pastedimage1609925466595v5.png

    3.Go Settings > Customizations > Customize the system > entities > opportunity > forms > open main form to click form porperties.

     pastedimage1609925411735v4.png

    4.Add web resource you just created.

     pastedimage1609925267683v1.png

    4.test.

    pastedimage1609925333738v2.png  pastedimage1609925391040v3.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: How to set value in custom field on basis of Business process flow stage

    Hello,

    You can check this - www.cloudfronts.com/.../

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans