Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Hide Form on Next Stage of a Business Process Flow

(0) ShareShare
ReportReport
Posted on by

Hi All,

I want to show / hide fields when Business process flow takes user to the next stage. Whats the best way to implement this ?

Should i use different forms and just switch them on next stage or JavaScript .. Any ideas please, not done this before

Thanks,

*This post is locked for comments

  • Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,205 on at
    RE: Hide Form on Next Stage of a Business Process Flow

    And don't forget to mark answer Verified if it resolves your issue.

    Best regards,

    Shahbaaz

  • Jay2014 Profile Picture
    Jay2014 on at
    RE: Hide Form on Next Stage of a Business Process Flow

    Thank you both, I will look into your suggested solutions

  • Verified answer
    gdas Profile Picture
    gdas 50,089 Moderator on at
    RE: Hide Form on Next Stage of a Business Process Flow

    Hi ,

    You can implement this using JavaScript method. Here is the code you only need to replace field Id and register "AttachProcessStageChange" function on load  event of your form. Here is the code

    //You need to register the function  AttachProcessStageChange on load of the form
    function AttachProcessStageChange() {
        Xrm.Page.data.process.addOnStageChange(StageChangeAction);
        Xrm.Page.data.process.addOnStageSelected(StageSelectedAction);
    }
    
    function StageChangeAction() {
        //This is for on change
    }
    //This function will fire at the time of stage selection
    function StageSelectedAction() {
        var stageName = Xrm.Page.data.process.getSelectedStage().getName().toString().toLowerCase(); //Return stage name  
        //var stageID = Xrm.Page.data.process.getSelectedStage().getId().toString().toLowerCase(); //  Stage Id will return GUID You can also do a check with the ID as well
        if (stageName = "Qualify Lead") {
    
            Xrm.Page.getControl("fieldId").setDisabled(true);  //Replace fieldId everywhere , this will hide form field
            Xrm.Page.getAttribute("fieldId").setSubmitMode("always"); //Replace fieldId
    
            if (Xrm.Page.ui.controls.get("header_process_fieldId") != null) { //Replace fieldId only
                Xrm.Page.getControl("header_process_fieldId").setDisabled(true);  //Add prefix "header_process_" with your field name to get the BPF field. 
            }
        }
    }
    


    Hope this helps.

  • Verified answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,205 on at
    RE: Hide Form on Next Stage of a Business Process Flow

    Hi Ncube

    You can use below code for hiding/showing the field on the change of BPF.

    function OnLoad() {

     // *** Whenever the stage changes trigger an onchange function

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

     // To remove the function if required ….. Xrm.Page.data.process.removeOnStageChange(stageOnChange);

     // *** Whenever a stage is selected trigger a function

     Xrm.Page.data.process.addOnStageSelected(stageSelected);

     // To remove the function is required …. Xrm.Page.data.process.removeOnStageSelected(stageSelected);

    }

    function stageOnChange() {

     stage = Xrm.Page.data.process.getActiveStage();

     Xrm.Page.getControl('fieldname1').setVisible(true);

     Xrm.Page.getControl('fieldname2').setVisible(false);

    }

    function stageSelected() {

     stage = Xrm.Page.data.process.getSelectedStage();

     Xrm.Page.getControl('fieldname1').setVisible(true);

     Xrm.Page.getControl('fieldname2').setVisible(false);

    }

    If you find it helpful,Please mark my answer as verified.

    Best Regards,

    Shahbaaz

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

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,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans