Condividi tramite


Show Members Sub Grid on Marketing List Form in Dynamics CRM 2011

In one of my recent engagement, my customer asked us to show members sub grid on the marketing list form. In out of box implementation, one has to click on links to see marketing list members and it also demands navigating out of marketing list form.

There were many challenges in configuring this sub-grid on the marketing list form –

  1. Marketing List Member is not a normal entity but it is a special “relationship entity”. You cannot list view for it.
  2. In Marketing List, members could be “Lead”, “Contact” or “Account”. So which sub-grid do we add?

We gave thought to many options ranging from dynamically binding a sub-grid with fetch XML to something custom in Silverlight.

 Finally, we finalized for a very simple solution.

Solution

The solution goes as following –

  1. On the marketing list form – add three tabs. In one tab add a sub-grid of “related records” for “Lead”. In other two tabs, do the same for “Account” and “Contact”. Give these tabs some nice “Label” something like “Marketing List Accounts”, “Marketing List Leads” and ““Marketing List Contacts”.  
  2. Write java script on Marketing List form (“On-Load” event, for “Create Form” type), which hides all three tabs on the form. Well, when creating a new marketing list, you don’t know the “Member Type” till the time you select and save.
  3. Finally, write java script on the “On-Load” event (for “Edit Form” type) which runs the following logic –
  • If Member Type is “Lead”, show ONLY the “Marketing List Leads” tab.
  • If Member Type is “Account”, show ONLY the “Marketing List Accounts” tab.
  • If Member Type is “Contact”, show ONLY the “Marketing List Contacts” tab.

The following java script when registered on the Marketing List Form “On-Load” event does all the magic –

function hidethelist() {                                                                                                                              

    if (Xrm.Page.ui.getFormType() ==1) {                                                         

                Xrm.Page.ui.tabs.get("leadtab").setVisible(false);

                Xrm.Page.ui.tabs.get("contacttab").setVisible(false);

                Xrm.Page.ui.tabs.get("accounttab").setVisible(false);

      }                                                                                                                        

                                                                                                                               

   if (Xrm.Page.ui.getFormType() ==2) {                      

        if (Xrm.Page.getAttribute("createdfromcode").getText() == 'Account') {                                                                             

Xrm.Page.ui.tabs.get("leadtab").setVisible(false);

                                Xrm.Page.ui.tabs.get("contacttab").setVisible(false);

                }              

        if (Xrm.Page.getAttribute("createdfromcode").getText() == 'Lead') {                                                                            

Xrm.Page.ui.tabs.get("contacttab").setVisible(false);

                                Xrm.Page.ui.tabs.get("accounttab").setVisible(false);          

   }                                                                                                                                                                           

        if (Xrm.Page.getAttribute("createdfromcode").getText() == 'Contact') {                                                                

Xrm.Page.ui.tabs.get("leadtab").setVisible(false);

                                Xrm.Page.ui.tabs.get("accounttab").setVisible(false); } }                                                                                                                          

}

The “leadtab”, “accounttab” and “contacttab” are the ids of three tabs we defined earlier.

Conclusion

This is a simple yet on-spot solution. It helps reduce navigation. Not sure, how relevant it will be in Orion but till then keep using when need comes. Thanks!

Comments

  • Anonymous
    December 16, 2016
    Hi I have tried but this doesnt work
  • Anonymous
    December 20, 2016
    Will this work on dynamic marketing list