locked
show section depending on optionset value RRS feed

  • Question

  • Hi..

    using java script i have to do the following.

    I have a field called appeal stage..type-option set

    if i select the value "appeal processing" in appeal stage, then the section called "processing" on the form should appear

    * by default the section is invisible

    Thursday, February 27, 2014 12:23 PM

All replies

  • Hi Amy,

    Something like this should work

    if (Xrm.Page.data.entity.attributes.get("optionsetattributename").getValue() == "your option value")
    {
    	Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(true);
    }
    

    Remember to wire this up in both page load and optionset on change.

    Thursday, February 27, 2014 12:39 PM
  • Hi Amy,

    Something like this should work

    if (Xrm.Page.data.entity.attributes.get("optionsetattributename").getValue() == "your option value")
    {
    	Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(true);
    }

    Remember to wire this up in both page load and optionset on change.

    The logic is correct, but for optionset the method getValue returns an int, for the text value it is necessary to use getText, also the else condition is missing.

    Something like this:

    var section = Xrm.Page.ui.tabs.get("yourtabname").sections.get("yoursectionname");
    if (Xrm.Page.data.entity.attributes.get("optionsetattributename").getText() == "your option text")
    {
        section.setVisible(true);
    }
    else {
        section.setVisible(false);
    }


    My blog: www.crmanswers.net - Rockstar 365 Profile

    • Proposed as answer by Atif Faisal Thursday, February 27, 2014 1:08 PM
    Thursday, February 27, 2014 1:02 PM