Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Multiple forms in single entity

$
0
0

I have 3 forms in the accounts entity. AccountA (default out of the box form), AccountB, AccountC

I have created a custom field (type: single line of text) to store the value of the form the record was created in. 

I used the following javascript to open the correct form based on the field value. Although the correct form is opening onLoad, I'm now experiencing other issues: When I create a new record and click on "save and close" or "save" it saves and automatically opens a new AccountA form. When I try to switch to AccountB or Account C form from the dropdown, it gives this the following pop up and again opens AccountA form.

Here is the code I used: 

function onLoad()
{

//if the form is update form
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("new_formname").getValue();
   // switch statement to assign the form to the picklist value
   //change the switch statement based on the forms numbers and picklist values
   switch (relType) {
       case 'AccountC':
           lblForm = "AccountC";
           break;
       case 'AccountB':
           lblForm = "AccountB";
           break;
       default:
           lblForm = "AccountA";
   }
   //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();
			   return;
           } //endif
       } //end for
   } //endif
}//endif


Please help me solve this problem. Thank you!  




Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images