Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to change entity form on stage change?

Posted on by Microsoft Employee

Hi!

I have a customer who wants a different form for each stage of opportunity entity sales process. Ie. different form for Offer and Negotiation stage.

I found a solution to change the form with javascript (Xrm.Page.ui.formSelector.items.get(formId).navigate( ); function). I can not however figure out how to trigger the said javascript on stage change.

Busines Process Flow has abiltiy to trigger workflow either on "Stage Entry" or "Stage Exit". I can not however figure out how to trigger my javascript (web resource)from the workflow.

I have two questions

How do I run web resource(javascript) from workflow?

Is there some other way I can change the form of an entity on stage change?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to change entity form on stage change?

    Thank you! This was really simple solution.

    For anyone else wondering same thing it is as simple as

    function OnFormLoad(){

    Xrm.Page.data.process.addOnStageChange(YourFunctionHere);

    }
    Then you just call the OnFormLoad function from web resources from form properties. 
  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to change entity form on stage change?

    You can use OnStageChange event:

    "This event occurs when the stage of a business process flow control changes. This event occurs when the user clicks the Next Stage or Move to previous stage buttons in the user interface or when a developer uses the formContext.data.process.moveNext or formContext.data.process.movePrevious methods. You can’t cancel the stage change using code in a handler for this event."

    Please refer to the documentation: docs.microsoft.com/.../onstagechange

    Let me know if you need some guidance to implement your code.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to change entity form on stage change?
    [quote user="Mehdi El Amri"]

    Hi,

    What version of CRM are you using?

    [/quote]

    Hi! 

    The version is

    2021 release wave 1 enabled

    Server version: 9.2.21035.00176

    Client version: 1.4.2511-2103.5

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to change entity form on stage change?

    Hi,

    What version of CRM are you using?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans