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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Pop up window error - JS

(1) ShareShare
ReportReport
Posted on by

message_5F00_From_5F00_Webpage.png

I am getting this error when I open an "opportunity" I believe it is.. a JS error, but have no idea how to fix it - or where to even start.

The same error does not come under any other section than "opportunities"  accounts, contacts open up just fine.

Please advise, let me know if you require any additional information.

Thanks!!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: Pop up window error - JS

    This is a error in your Opportunities onload function in javascript. As a system admin, go to an opportunity. Click the customize tab, ,then click form. Click on the Form Properties button. On the bottom of the window you should see a grid with Library, Function, Enabed. Note the js file to the left of the onload function. Open that file by double clicking it in the above grid. Copy the file into Visual studio or notepad++.

    The problem is that somewhere you are trying to use the getValue function on an empty field from the form. Search for all instances of the getValue function and be sure that the id (form field) has data in it. To fix this you will need to detect if the field is null (empty) before you try to get the value of it.

    Wrap the code in an 'if' statement such as this:

    if (Xrm.Page.getAttribute("name").getValue() != null) {

        var name = Xrm.Page.getAttribute("name").getValue();
    }

  • Royal King Profile Picture
    27,686 on at
    RE: Pop up window error - JS

    it looks like you are trying to retrieve value from the field that does not exists in the form. I would suggest checking your script function and validate it for correctness.

    If you post your script may be we can point out issue.

  • Community Member Profile Picture
    on at
    RE: Pop up window error - JS

    Does this look correct?

    function HideForms () {

       var Medical = Xrm.Page.getAttribute("new_medicalsales").getValue()

       var Tech = Xrm.Page.getAttribute("new_technicalsales").getValue()

       if (Medical == true) {

           Xrm.Page.ui.tabs.get("medical").setVisible(true);

       }

       if (Medical == false) {

           Xrm.Page.ui.tabs.get("medical").setVisible(false);

       }

       if (Tech == true) {

           Xrm.Page.ui.tabs.get("technical").setVisible(true);

       }

       if (Tech == false) {

           Xrm.Page.ui.tabs.get("technical").setVisible(false);

       }

    }

    function HideTest() {

       //Use this to hide tabs, designed for testing

       Xrm.Page.ui.tabs.get("medical").setVisible(false);

    }

  • ScottDurow Profile Picture
    21 on at
    RE: Pop up window error - JS

    It is a good idea to learn how to debug these kind of script errors. First you'll need to put a 'debugger' statement in your Webresource javascript at the point you want to debug - then you can press F12 in your browser to open the debugger. When the debugger statement is hit the browser will break into your code so you can examine the value of objects and step through line by line until you identity the issue. This will be a real time saver once you've mastered this since it'll allow you to quickly find script errors.

    Hope this helps,

    Scott

  • Suggested answer
    Abed Haniyah Profile Picture
    4,287 on at
    RE: Pop up window error - JS

    You can check your JS code online by going to : http://jshint.com/ or www.javascriptlint.com/online_lint.php

    Hope this helps.

  • Royal King Profile Picture
    27,686 on at
    RE: Pop up window error - JS

    issue might be happening in one of the line shown below.

    Are you sure new_medicalsales and new_technicalsales fields exists in a form?

    var Medical = Xrm.Page.getAttribute("new_medicalsales").getValue()

    var Tech = Xrm.Page.getAttribute("new_technicalsales").getValue()

    I would check whether these 2 fields exists in the form not , if it exists check the attribute name.

  • pmdci Profile Picture
    1,032 on at
    RE: Pop up window error - JS

    Gareth Tucker has a post in his blog named "JavaScript Reference" which I found to be of a great help during my early days. It might find it useful.

    garethtuckercrm.com/.../jscript-reference-for-microsoft-dynamics-crm-2011

    Hope this helps you!

    Just out of curiosity, what are the type of fields this JavaScript is referencing? There are best-practices on how referencing fields depending on the field types -- particularly with lookups, as you need to add some conditional checks to see if the field contains a value or not.

    Also bear in mind that fields must exist in the form for you to reference them with JavaScript. You can always add fields and hide them (or the section they are in) if they are not meant to be seen by the user and only manipulated by the JavaScript.

    Regards,

    P.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Pop up window error - JS

    Very helpful thank you all for your comments.

    It was easier to Remove the Event handler - so that is what I did.

    But now I have learned how to access this section of the product and am much wiser for it - thanks again!

  • pmdci Profile Picture
    1,032 on at
    RE: Pop up window error - JS

    Glad this worked. But my first thought is that this code was there for a reason...

    So it is important to identify whether there is no longer a case for the code you have removed.

    Perhaps this code was there to support a business requirement that it is no longer needed, or this code was replaced by another code, or by an alternative (e.g. workflow or plugin). But it might as well be that this code broke after some changes, but that does not mean that the business case behind is no longer needed.

    Regards,

    P.

  • Community Member Profile Picture
    on at
    RE: Pop up window error - JS

    You're absolutely correct, I had removed the fields it was calling a few weeks ago, and only recently published the updates.

    This lead to the issue -> so I simply removed it. It was just showing/hiding a field - since the field wasn't there - it spat out an error.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans