Quantcast
Channel: Neil Parkhurst's Groups Activities
Viewing all articles
Browse latest Browse all 1692

Changing a Form based on option set Value

$
0
0

Hello,

I have 4 forms in an entity. I created a default form, based on the option set value I would like to change the form.  I tried to use the below code on the default form, but nothing is happening. Do I need to have 4 if blocks with the associated option set number? Thanks!

function showForm() {


        if (Xrm.Page.ui.getFormType()==2){
            // variable to store the name of the form
            var lblForm;

            // get the value picklist field
            var relType = Xrm.Page.getAttribute("optionset").getValue();
        }



        switch (relType) {
            case 1:
                lblForm = "Form1";
                break;
            case 2:
                lblForm = "Form2";
                break;
            case 3:
                lblForm = "Form3";
                break;
            case 4:
                lblForm = "Form4";
                break;
            default:
                lblForm = "Information";
        }
        //check if the current form is form need to be displayed based on the value
        if (Xrm.Page.ui.formSelector.getCurrentItem().getLabel() != lblForm) {
            var items = Xrm.Page.ui.formSelector.items.get();
            for (var i in items) {
                var item = items[i];
                var itemId = item.getId();
                var itemLabel = item.getLabel()

                if (itemLabel == lblForm) {
                    //navigate to the form
                    item.navigate();
                } //endif
            } //end for
        } //endif
    }//endif

Viewing all articles
Browse latest Browse all 1692

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>