none
crm 2011: null window.top.opener.parent.Xrm.Page when creating new case from account sub-grid

    Question

  • I have added a case sub-grid to account form.

    If i set focus to the sub-grid, ribbon changes according.

    When i push new, it opens a new case, but the onload script for case entity shows there is no window.opener.

    If i create a case from account entity´s normal options, the window.operer is there.

    is this by design or is this bug?

     

    Sunday, March 06, 2011 4:35 PM

Answers

  • I'm late to the party here, but I thought this is worth posting so that people can find the solution.

    The standard way of using window.parent.opener.Xrm.Page.getAttribute("Attribute_Name") Will not work.
    You cannot call the getAttribute method from here as it's a "short-cut" method which does not exist when firing from a grid.

    Here is the solution for getting parent attribute data, when opening a new record from grid view.

    window.parent.opener.Xrm.Page.data.entity.attributes.get("Attribute_Name");                    //To get the attribute
    window.parent.opener.Xrm.Page.data.entity.attributes.get("Attribute_Name").getValue();    //To get an attribute value

    Having said that, the above will not work when firing from a form. My solution is to use both methods in my events, with a try/catch surrounding them. then, my remaining logic begins on whichever is successful.

    Hope this helps.

    Craig 


    My Blog
    Twitter
    Tuesday, June 14, 2011 11:33 AM

All replies

  • Its probably because the sub grid is in its own iframe so you may need to inspect the DOm using the IE dev tool to see if there is another path like parentWindow, etc that isn't null.
    MSCRM Bing'd - http://bingsoft.wordpress.com
    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM Forum Guidance on how to Help Us Help You
    Sunday, March 06, 2011 4:41 PM
    Moderator
  • could you please point me where to find instructions how this is done with IE tools?
    Sunday, March 06, 2011 6:27 PM
  • Place the key word debugger; in your code just before the window.opener... line, and save/publish. then load your page. Pressing F12 will bring up IE dev tools and then from there you need to start debugging, refresh the page so the debugger is triggered. Then place a watch on the window object (right click on window.opener and select Add Watch). Then from here you have traverse the DOM. I think it will be something like window.top.parentWindow.document.....


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM Forum Guidance on how to Help Us Help You
    Sunday, March 06, 2011 9:20 PM
    Moderator
  • Thanks Rrhett for your help. With your help i learned a lot of how CRM page is built. Unfortunately as my knowledge is quite limited, i could not find the correct path to the parent form.
    Tuesday, March 15, 2011 7:10 PM
  • I'm late to the party here, but I thought this is worth posting so that people can find the solution.

    The standard way of using window.parent.opener.Xrm.Page.getAttribute("Attribute_Name") Will not work.
    You cannot call the getAttribute method from here as it's a "short-cut" method which does not exist when firing from a grid.

    Here is the solution for getting parent attribute data, when opening a new record from grid view.

    window.parent.opener.Xrm.Page.data.entity.attributes.get("Attribute_Name");                    //To get the attribute
    window.parent.opener.Xrm.Page.data.entity.attributes.get("Attribute_Name").getValue();    //To get an attribute value

    Having said that, the above will not work when firing from a form. My solution is to use both methods in my events, with a try/catch surrounding them. then, my remaining logic begins on whichever is successful.

    Hope this helps.

    Craig 


    My Blog
    Twitter
    Tuesday, June 14, 2011 11:33 AM