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)

How to fix invalid reference

(0) ShareShare
ReportReport
Posted on by

I'm new to Dynamics CRM, with only a little background in JavaScript. I need some insight...

I'm trying to fix a form (Sales > Leads > New Lead) in a CRM project that someone else wrote but that has never worked correctly. The form contains a Product Categories list box that's apparently an iFrame within the main form.

New-Lead-page.png

Two web resources are associated with that list. One (new_PromptLeadProductPage.htm) has JavaScript functions onbodyload() and oncheck(). The other one (new_PromptLeadProductService.js) contains functions for fetching and sorting the product categories, including one named GetAllProducts.

The first line in onbodyload() is

var objProducts =parent.window.GetAllProducts();

When that line executes, I get an error in the console log, "Uncaught TypeError: parent.window.GetAllProducts is not a function".

What do I need in this statement in place of "parent.window" to refer to the function in the ...Service.js resource?

*This post is locked for comments

I have the same question (0)
  • Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Can you try using the following code?

    var objProducts = window.parent.GetAllProducts();

    Hope this helps.

  • Suggested answer
    keyur7379 Profile Picture
    902 on at

    Hey ,

    First you have to make sure that  HTML resource (new_PromptLeadProductPage.htm) have ref of new_PromptLeadProductService.js . If not the you have to add new_PromptLeadProductService.js ref

    ex.

    add this between <head>{Add your ref here}</head>

    <script src="https://<Your CRM instance name>//WebResources/new_PromptLeadProductService.js" type="text/javascript"></script>

     


    Now you can directly access GetAllProducts(); this method

    ex :

    var objProducts =GetAllProducts();



    If helpful , please mark as verified.
  • Community Member Profile Picture
    on at

    Use this:

    var objProducts =parent.GetAllProducts();

  • Community Member Profile Picture
    on at

    Thank you. This did get me past the current error. Of course, once that happened, a different error occurred, but it wasn't related to this issue. The old code was using SOAP and CRMFetchKit, and it will have to be replaced with oData queries. I have a lot of work to do!

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