locked
Records in IFrame from N:N relationships RRS feed

  • Question

  • Hi,

    We have a custom entity "store" which has a N:N relation with contact entity.

    we have another custom entity named "visit" which has a lookup for "store" and an IFrame named contacts.

    I need to display all the contacts which are related to the "store" record which is selected in the lookup field.

    I was able to get records when the "store" had 1:N relation with contact. But it is not working for N:N.

    Thanks in advance.

     

    Yogi

    Wednesday, July 28, 2010 11:56 AM

Answers

  • function LinkGrid(frameName, oType, tabSet, ObjectId) // note last parameter is optional and not usually needed
    {
        if(ObjectId==null)  ObjectId =  crmForm.ObjectId;

        var myFrame = document.all[frameName];
        var myWindow = document.frames[frameName];

        if (crmForm.FormType == 1)//and checking if the entity has been saved (if not, display a blank)
        {
            document.all[frameName].src = "about:blank";
            document.all[frameName].parentElement.parentElement.parentElement.style.display = 'none';
        }
        else // else if this is a saved record we will set the URL of the iframe to that of the commercial dept grid
        {
            myFrame.src = "areas.aspx?oId=" + ObjectId + "&oType=" + oType + "&security=852023&roleOrd=1&tabSet=" + tabSet;

            myFrame.name = myFrame.id;
            myFrame.style.borderWidth = '0px';

            myFrame.onreadystatechange = function() {
                if (myWindow.document.readyState == 'complete') {
                    myWindow.document.body.style.backgroundColor = '#EAF3FF';
                    myWindow.document.getElementsByTagName('TABLE')[0].style.borderLeftWidth = '0px';
                }
            }
        }
    }

     


    if( crmForm.all.new_doorid.DataValue != null )
    {
       var DoorID = crmForm.all.new_doorid.DataValue[0].id.toString().replace("{", "").replace("}", "");
       LinkGrid("IFRAME_MattressSlots", 10010, 'new_new_door_new_mattressslot', DoorID);
       LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', DoorID,2);
       LinkGrid("IFRAME_PILLOWS", 10010, 'new_new_door_new_pillowsonsite', DoorID);
    }
    else
    {
           LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', "",2);
    }


    In the case of N to N relation as a tabSet you should pass 'area' + the name of the relation like 'areanew_contact_new_door'.

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Friday, July 30, 2010 4:32 PM
    Moderator

All replies

  • Wednesday, July 28, 2010 12:03 PM
    Moderator
  • I have set the roleOrd parameter already...

    But it is still not working for me...

    Wednesday, July 28, 2010 12:40 PM
  • Can you paste your code here for investigation?

    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, July 28, 2010 12:40 PM
    Moderator
  • function LinkGrid(frameName, oType, tabSet, ObjectId) // note last parameter is optional and not usually needed
    {
        if(ObjectId==null)  ObjectId =  crmForm.ObjectId;

        var myFrame = document.all[frameName];
        var myWindow = document.frames[frameName];

        if (crmForm.FormType == 1)//and checking if the entity has been saved (if not, display a blank)
        {
            document.all[frameName].src = "about:blank";
            document.all[frameName].parentElement.parentElement.parentElement.style.display = 'none';
        }
        else // else if this is a saved record we will set the URL of the iframe to that of the commercial dept grid
        {
            myFrame.src = "areas.aspx?oId=" + ObjectId + "&oType=" + oType + "&security=852023&roleOrd=1&tabSet=" + tabSet;

            myFrame.name = myFrame.id;
            myFrame.style.borderWidth = '0px';

            myFrame.onreadystatechange = function() {
                if (myWindow.document.readyState == 'complete') {
                    myWindow.document.body.style.backgroundColor = '#EAF3FF';
                    myWindow.document.getElementsByTagName('TABLE')[0].style.borderLeftWidth = '0px';
                }
            }
        }
    }

     


    if( crmForm.all.new_doorid.DataValue != null )
    {
       var DoorID = crmForm.all.new_doorid.DataValue[0].id.toString().replace("{", "").replace("}", "");
       LinkGrid("IFRAME_MattressSlots", 10010, 'new_new_door_new_mattressslot', DoorID);
       LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', DoorID,2);
       LinkGrid("IFRAME_PILLOWS", 10010, 'new_new_door_new_pillowsonsite', DoorID);
    }
    else
    {
           LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', "",2);
    }

    Friday, July 30, 2010 3:58 PM
  • Here is a link to multiple links, this one also integrates proper formatting of the IFRAME

    http://bradleymlaw.com/wp/2010/06/28/add-iframe-to-a-form-system-and-custom-entities-plus-format-iframe/

     

    Friday, July 30, 2010 4:10 PM
  • function LinkGrid(frameName, oType, tabSet, ObjectId) // note last parameter is optional and not usually needed
    {
        if(ObjectId==null)  ObjectId =  crmForm.ObjectId;

        var myFrame = document.all[frameName];
        var myWindow = document.frames[frameName];

        if (crmForm.FormType == 1)//and checking if the entity has been saved (if not, display a blank)
        {
            document.all[frameName].src = "about:blank";
            document.all[frameName].parentElement.parentElement.parentElement.style.display = 'none';
        }
        else // else if this is a saved record we will set the URL of the iframe to that of the commercial dept grid
        {
            myFrame.src = "areas.aspx?oId=" + ObjectId + "&oType=" + oType + "&security=852023&roleOrd=1&tabSet=" + tabSet;

            myFrame.name = myFrame.id;
            myFrame.style.borderWidth = '0px';

            myFrame.onreadystatechange = function() {
                if (myWindow.document.readyState == 'complete') {
                    myWindow.document.body.style.backgroundColor = '#EAF3FF';
                    myWindow.document.getElementsByTagName('TABLE')[0].style.borderLeftWidth = '0px';
                }
            }
        }
    }

     


    if( crmForm.all.new_doorid.DataValue != null )
    {
       var DoorID = crmForm.all.new_doorid.DataValue[0].id.toString().replace("{", "").replace("}", "");
       LinkGrid("IFRAME_MattressSlots", 10010, 'new_new_door_new_mattressslot', DoorID);
       LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', DoorID,2);
       LinkGrid("IFRAME_PILLOWS", 10010, 'new_new_door_new_pillowsonsite', DoorID);
    }
    else
    {
           LinkGrid2("IFRAME_Contacts", 10010, 'new_contact_new_door', "",2);
    }


    In the case of N to N relation as a tabSet you should pass 'area' + the name of the relation like 'areanew_contact_new_door'.

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Friday, July 30, 2010 4:32 PM
    Moderator
  • hey thanx Andriy!!

    It workd :)

    Saturday, July 31, 2010 7:08 AM
  • Hey frenz,

    The earlier issue got resolved, but now I m facing another issue.

    The contacts are getting displayed in the IFrame. But when I try to add an existing contact it gives an error. I am logged in as Sys Admin, so i guess privileges is not an issue.

    What cud possible be the issue?

    Thanx

    Yogi

    Monday, August 2, 2010 9:10 AM