Control formview by optionset on form RRS feed

  • Question

  • Hi

    I would like to control what form view the users gets,
    by an option set on the form. E.g. Client type = 1, the users see one form, and
    if Client type = 2, the user gets another form.

    How can I do that?



    Thursday, May 22, 2014 7:37 AM

All replies

  • In CRM 2011, if the user is allowed to see more than one form, there is a native drop down on the left side and above the navigation that allows the user to change forms.

    I haven't played with CRM 2013 too much, but I assume there must be something similar there as well.

    Jason Peterson

    Thursday, May 22, 2014 2:36 PM
  • Hi Jason

    Yes, you are right. But that will have effect on every Account form. I want different forms displayed to the same user, depending on an
    option set pick list on the form: <o:p></o:p>

    If the relationship type is one value, one form is displayed. If the relationship type is another, another form is displayed.<o:p></o:p>

    Best Regards


    Thursday, May 22, 2014 3:32 PM
  • Hi Jacob,

    The following code should do the trick. You will need to tweak it a bit to meet your specific requirements, but it should set you on the right track!

    function switchToCorrectForm() {
        var formName = "information";
        var myOption = Xrm.Page.getAttribute("myoptionset").getValue();
        if (myOption == 100000000) {
            formName = "customform1";
        else if (myOption == 100000001) {
            formName = "customform2";
        var currentForm = Xrm.Page.ui.formSelector.getCurrentItem();
        var availableForms = Xrm.Page.ui.formSelector.items.get();
        // If we are already on the form, we don't need to change forms
        if (currentForm.getLabel().toLowerCase() != formName.toLowerCase()) {
            for (var i in availableForms) {
                var form = availableForms[i];
                if (form.getLabel().toLowerCase() == formName.toLowerCase()) {
    If this has helped you, please mark as answer, or reply if you need more information. :)

    ~ Atomic Coder

    • Proposed as answer by Nathan Eccles Friday, May 30, 2014 11:29 PM
    Friday, May 30, 2014 2:28 PM