locked
CRM 2011 Select Form layout depending on an field value RRS feed

  • Question

  • I have a very tricky requirement for CRM 2011 that I must confirm if it's possible. Here it is:
    We need to define several forms layouts for one entity, let say, 20 forms. And, when opening a form either for a new entity record or for editing an existing record, depending on a value of one of the entity attributes, I need to select the form layout to show.

    I know that the purpose of having multiple forms is for tie a form to a security role. But, I was wondering if I can tie an entity form layout to any other attribute in the entity. Do you thing that is possible?

    Any assistance would be greatly appreciated.

     

    Tuesday, May 17, 2011 12:44 AM

Answers

  • Hi Carlton, i just want to know if you have any solution to keep away from loading form more then once?

    in your scrnario, you loaded form first, and then choose the right form to load again if the form is not exactlly the form u want.

    so i have a quite samiliar requirment with you ,but we want to load the firm just once.

    • Marked as answer by MarkX Wednesday, June 8, 2011 10:14 PM
    Thursday, May 26, 2011 3:54 AM

All replies

  • It seems possible, though I haven't done so. You may borrow code from here. Note that you need to manage the infinite loop issue that the poster has mentioned. I would say query string parameter could rescue you from the infinite loop.
    Daniel Cai | http://danielcai.blogspot.com
    • Proposed as answer by shu nan Wednesday, July 6, 2011 7:23 AM
    • Unproposed as answer by shu nan Wednesday, July 6, 2011 7:23 AM
    Tuesday, May 17, 2011 1:57 AM
  • I've done it with a contact form using a Contact Type drop down and the form names the values in the picklist with this jscript:

     

    var setform = function()
    {
     var currentForm= Xrm.Page.ui.formSelector.getCurrentItem().getId();
     var Information;
     var cType = Xrm.Page.data.entity.attributes.get('my_contacttype').getText().toLowerCase();
     var forms = Xrm.Page.ui.formSelector.items.get();
     var i = 0;
     for (i=0;i<forms.length;i++)
     {
      if (forms[i].getLabel().toLowerCase()==cType) {
       if (currentForm!=forms[i].getId()) {
        forms[i].navigate();
       }
       return;
      }
      if (forms[i].getLabel().toLowerCase()=='information') {
       Information=forms[i];
      }
     }
     if (currentForm!=Information.getId())
     {
      Information.navigate();
     }
    }
    

     

    My Information Form is very basic and is the default.  I just call it in the onload of the form.


    Carlton Colter | http://www.mscrmblogger.com
    Tuesday, May 17, 2011 3:49 AM
  • Hi Carlton, i just want to know if you have any solution to keep away from loading form more then once?

    in your scrnario, you loaded form first, and then choose the right form to load again if the form is not exactlly the form u want.

    so i have a quite samiliar requirment with you ,but we want to load the firm just once.

    • Marked as answer by MarkX Wednesday, June 8, 2011 10:14 PM
    Thursday, May 26, 2011 3:54 AM
  • Hey, MarkX, check this post. maybe this will help u a little bit.
    Wednesday, July 20, 2011 1:58 AM