Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

how to show/hide subgrid based on two option change value in dynamics crm?

Posted on by Microsoft Employee

Hi Experts,

I add a Two Option field value in Opportunity entity and when the value of change two option then "Product Line Items" subgrid hide show?

Please give me suggestion.

How to do this?

Thanks in advance!

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: how to show/hide subgrid based on two option change value in dynamics crm?

    Hi Finance,

    I would suggest that instead of doing this logic on the subgrid itself, you do it on a section on the form.

    Put the subgrid on the section, and add a change event to the Two Options attribute

    function twoOptionsOnChange()

    {

      var selectedValue = Xrm.Page.getAttribute("new_TwoOptions").getValue();

      Xrm.Page.ui.tabs.get("subgridTabName").sections.get("subgridSectionName").setVisible(selectedValue);

    }

    Hope this helps

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: how to show/hide subgrid based on two option change value in dynamics crm?

    Hi ,

    Instead of hide the subgrid control you can hide the section name or tab where your subgrid included.

    Try With this -

    function ShowHideSubgrid() {
        var obj = Xrm.Page.getAttribute("provide fieldSchemaName of optionset field");
        if (obj != null) {
            if (obj.getText() == "SomeText") // You can also check value using obj.getValue()
            {
                Xrm.Page.ui.tabs.get("tabName").sections.get("sectionName").setVisible(false); //Hide Section - Replace Tab Name and Section Name
                Xrm.Page.ui.tabs.get("tabName").setVisible(false);// If the subgrid inside TAB Hide Tab
            }
            else
            {
                Xrm.Page.ui.tabs.get("tabName").sections.get("sectionName").setVisible(true); // show Section -Replace Tab Name and Section Name
                Xrm.Page.ui.tabs.get("tabName").setVisible(true); // If the subgrid inside tab show Tab
    
            }
        }
    }


  • Suggested answer
    keyur7379 Profile Picture
    keyur7379 900 on at
    RE: how to show/hide subgrid based on two option change value in dynamics crm?

    Hi FinanceOpreation,

    - Create new tab. Add this sub grid to this tab.

    - On change event of yes/no field you can register java script code to hide/show this tab

    Thanks,

    keyur shah.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: how to show/hide subgrid based on two option change value in dynamics crm?

    Hi,

    refer to below post.

    community.dynamics.com/.../159700

  • Suggested answer
    Manju Augustine Profile Picture
    Manju Augustine 140 on at
    RE: how to show/hide subgrid based on two option change value in dynamics crm?

    Hi,

    Please try this javascript code on change of the required two option field.

        var fieldvalue = Xrm.Page.getAttribute('your two option field').getValue();
        if(fieldvalue == 1)
        {
            Xrm.Page.ui.controls.get('Subgrid name').setVisible(true);
        }
        else
        {
            Xrm.Page.ui.controls.get('Subgrid name').setVisible(false);
        }

    Thanks,

    Manju

    If found useful, please mark the answer as verified.

      

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans