Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Hide and show Subgrids Based on BPF Stages

(0) ShareShare
ReportReport
Posted on by 215

Hi All,  i have 3 subgrids on lead entity ,they are "Application" , "Interview", " Educational Details", on formtype 1 and 2 i am setting the visibility to false setVisible(false)  and i have a BPF and stages as Application , Interview,Education Details,

whenever i move to "Application" Stage , the Application subgrid should be shown ,  its working fine for the first stage move and not working for the next stages 

i am using "addOnStageChange " Event?

*This post is locked for comments

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,231 on at
    RE: Hide and show Subgrids Based on BPF Stages

    Hi pillanagrovi sainath,

    You can use below code to get name of stage, so further on using stage name you can hide subgrid/section/tab.

    function onFormOnload()

    {

       debugger;

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

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

    }

    function stageOnChange()

    {

       debugger;

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

       alert("The stage has changed to " + stage.getName());

    }

  • RE: Hide and show Subgrids Based on BPF Stages

    Hi, i have tried it on Onload also but it i dint work anyway thanks , i have now added those subgrids on the tab and by default i am hiding those tab and onstagechange i am showing the tab , its now working fine, thanks for the response ravi

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 Moderator on at
    RE: Hide and show Subgrids Based on BPF Stages

    Hi,

    Are you also adding the addOnStageChange event on form load as well? If not, could you please try adding it on firm load?

    formcontext.data.process.addOnStageChange(stagechanged);

  • RE: Hide and show Subgrids Based on BPF Stages

    Hi Ravi, pls review the code

    function bpfstagechange(Executioncontext){

    debugger;

    var formcontext = Executioncontext.getFormContext();

    if( formcontext.ui.getFormType()==1 || formcontext.ui.getFormType()==2)

    {

    formcontext.getControl("Application").setVisible(false);

    formcontext.getControl("Interview").setVisible(false);

    formcontext.getControl("Education").setVisible(false);

    }

    }

    function onsave(Executioncontext)

    {

    debugger;

    var formcontext = Executioncontext.getFormContext();

    formcontext.data.process.addOnStageChange(stagechanged);

    }

    function stagechanged()

    {var bool = true;

    debugger;

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

      var   stagename = activestage.getName();

    if(stagename == "Student Interview")

    {

    var interviewsubgrid = Xrm.Page.ui.controls.get("Interview");

    interviewsubgrid.setVisible(true);

    interviewsubgrid.refresh();

    bool = false;

    //Xrm.Page.getControl("Interview").setVisible(true);

    }

       if(stagename== "Matriculated")

    {

    var educationsubgrid = Xrm.Page.ui.controls.get("Education");

    educationsubgrid.setVisible(true);

    educationsubgrid.refresh();

    //Xrm.Page.getControl("Education").setVisible(true);

    }

    if(stagename == "Application")

    {

    var applicationsubgrid = Xrm.Page.ui.controls.get("Application");

    applicationsubgrid.setVisible(true);

    applicationsubgrid.refresh();

    //Xrm.Page.getControl("Application").setVisible(true);

    }

    }

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 Moderator on at
    RE: Hide and show Subgrids Based on BPF Stages

    Hi,

    If you have added the code correctly ( referencing the subgrid name correctly) then the js should work on stage change (provided you are calling the same JS on addonstagechange event.

    you could share the code here for review.

    Do note that addOnStageChange  triggers when you actualy click next/ previous on the BPF and not when you select the stage ( which is triggered by addOnStageSelected).

    Hope this helps

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

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans