web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

window.parent.document.getElementById() returns null whereas document.getElementById() returns the html div element .

(0) ShareShare
ReportReport
Posted on by 370

windowparent.png

here is a screenshot of the console of this page where i get results for document.getElementById but not for window.getElementById. what is the difference between these two?ultimately all the controls are in the document node isn't it.?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Bas van de Sande Profile Picture
    4,383 on at

    Hi Prem,

    please don't interact with the DOM directly.  The guys of PowerObjects wrote a great article on the do's and dont's in using javascript in CRM

    [View:http://www.powerobjects.com/2015/10/09/javascript-best-practices-for-microsoft-dynamics-crm-2015/:750:50]

    I quote:

    When dealing with the CRM UI, the SDK documents the exposed objects and the properties that are available to interface with. As a general rule, you should adhere to the exposed objects and interact with them via the documented properties and methods using the Xrm.Page object model.

    Many developers who know JavaScript and understand that these controls can be found in the HTML tend to go straight to the HTML DOM and manipulate the UI in this manner. This basically bypasses the supported means that is documented in the SDK. The problem with this approach is that the Microsoft Dynamics CRM development team reserves the right to change how pages are composed, all the way down to the ID values for elements. So by using the Xrm.Page object model, you can be assured that your code is protected from future changes in how pages are implemented.

    For example, if you were navigating the HTML DOM structure (instead of using the Xrm.Page protocol) and using window.getElementById or even manipulating the innerHTML or outerHTML, an update rollup or a service pack could cause your script to fail. Additionally, the DOM structure can be different from one browser to the next, so using this navigation method introduces risk, while using the documented API of the Xrm.Page object model has no navigation risks.

    Calling the javascript DOM directly is not supported in CRM.

    I hope this helps you further.

    Bas

  • Prem27 Profile Picture
    370 on at

    Thankyou Bas for this invaluable info

  • Prem27 Profile Picture
    370 on at

    Thank you Bas for this invaluable info

  • Prem27 Profile Picture
    370 on at

    Actually Bas, this control is a subgrid and i wan't to use SetParameter method to set the values, but Xrm.Page.getControl() doesn't support this method but document.getElementById does but still my records are not bound to the grid. so i was working on a suggestion to use window.parent.document.getElementById, but that too gives null.

    I'm stuck with the subgrid!!

  • Bas van de Sande Profile Picture
    4,383 on at

    What version of CRM are you on?

    as of CRM 2015 update 1 you have javascript methods to tinker with the grid.

    msdn.microsoft.com/.../dn932126.aspx

    for older CRM versions, please check:

    ribbonworkbench.uservoice.com/.../129783-pass-the-currently-selected-grid-row-s-to-a-custo

    or

    mehmetgunen.com/crm-2013-subgrid-javascript-operations

    I hope this helps you

    Bas

  • Prem27 Profile Picture
    370 on at

    Hi bas, My crm is on-prem version 7.0.0002.0053.  i have tried all these methods unfortunately none worked for me.

  • Bas van de Sande Profile Picture
    4,383 on at

    Hi Prem,

    can you explain to me what you want to do?

    As far as I understand it, you try to bind records to the subgrid?

    then you probably need this one:

    joshimandarblog.wordpress.com/.../crm-2015-applying-custom-fetchxml-to-a-subgrid-using-javascript

    Bas

  • Bas van de Sande Profile Picture
    4,383 on at

    don't forget to read the discussion below the article.

    for now you can use the method described in the article. Once you are running CRM 2015 update 1 or higher, interactions with the DOM are no longer allowed

    Bas

  • Prem27 Profile Picture
    370 on at

    Bas,

    I have two entities(project and project members),these have a N:N relationship between them.there is another entity "case",and on form of case we have project field. Now i am querying names of all the project members from the N:N table and filtering them on basis of the project selected on the case form . i want to create a view of these records and associate it to a sub grid on case form.

    here is the code snippet being used to associate the view to sub grid:

        var callbackRef = Mscrm.Utilities.createCallbackFunctionObject("locAssocObjAction", this, parameters, false);

           //pops the lookup window with our view injected

           var lookupItems = LookupObjectsWithCallback(callbackRef, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);

       }

    but lookup items returns null and yes a lookup window is popped but it consists project as primary entity and views related to project are displayed.Case-HGF-_2D00_-Microsoft-Dynamics-CRM-_2D00_-Internet-Explorer_5F00_2016_2D00_02_2D00_19_5F00_14_2D00_46_2D00_20.png

  • Bas van de Sande Profile Picture
    4,383 on at

    Hi Prem,

    so if I understand you correctly:

    using  the project and case lookups you want to filter the project members grid?

    Bas

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans