CRM 4.0 Entity Grid on Custom Page - JavaScript Error

คำตอบ CRM 4.0 Entity Grid on Custom Page - JavaScript Error

  • 6. června 2009 17:29
     
     

    I am creating a page for easily navigating  2 entities (master-detail) bound by a many to many relationship.
    I have a custom ASPX page which is a container for 2 IFrames.
    1. Iframe1 - Url to load the Master Entity's default view.
    2. IFrame2 - Url to load the Associated Entity View. Dynamically Changing Url on IFrame1's Grid's onclick event.

    The code works perfectly and i am able to see IFrame2 update with the associated records of the selected row from IFrame1. However, the "Add Existing" button does not work on IFrame2. It throws a script exception as it has a "top.locAssocObj" reference. Since top refers to the ancestor window (my custom aspx) which does not have any Crm script references, it fails. I tried to inject script into the grid to replace "top." with "parent." - However i got an access denied exception.

    Any pointers on getting this to work? I have to have it in a custom aspx page which is docked in Crm using SiteMap. I intend to have 4 grids on this page for efficient data entry/visualization.

    Regards,
    Maruf

Všechny reakce

  • 6. června 2009 20:20
    Moderátor
     
     Odpovědět
    Hi, Maruf.

    I suggest you to open folder with your Crm web site and search  js file which contains 'locAssocObj' text. When file will be found justt add this file to scripts on your custom page.

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
  • 6. června 2009 21:17
     
     

    Thanks for your response. I actually wanted to avoid adding Crm scripts to my page. However, if there is no alternative, i can go with that solution. Also, I wanted a way to use to ORG_UNIQUE_NAME and other global functions like GenerateAuthenticationHeader in my ASPX Page. Not sure if that is doable.


    Thanks,
    Maruf

    • Upravený Maruf 6. června 2009 21:17 Edit
    •  
  • 6. června 2009 21:40
     
     
    Also, I noted that locAssocObj calls AssociateObjects function which uses RemoteCommand. I am not sure if all those references would work from my custom page...Any ideas?


    function locAssocObj(iType , sSubType, sAssociationName, iRoleOrdinal)
    {
    var lookupItems = LookupObjects( null, "multi", "", iType, 0 );
    if (lookupItems)
    {
    if ( lookupItems.items.length > 0 )
    {
    AssociateObjects( crmFormSubmit.crmFormSubmitObjectType.value, crmFormSubmit.crmFormSubmitId.value, iType, lookupItems, iRoleOrdinal==2 , sSubType, sAssociationName);
    }
    }
    }
    function AssociateObjects( type1, id1, type2, objects, parentInitiated, sSubType , sAssociationName )
    {
    var commandAssociate = new RemoteCommand("AssociateRecords", "Associate");
    ...
    }


    Apologies for directly pasting the code here. Unfortunately, I was having trouble with the Code Block Editor.
  • 6. června 2009 21:51
    Moderátor
     
     Odpovědět
    Hi, Maruf.

    If you want your custom page to work like Microsoft CRM does - you have to add references to all required scripts.

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com