JavaScript Web Resource referenced in HTML Web Resource – not working

0
55
Forum Post: Change the Filter On option on Opportunity Associated View for Account form


Hi all,

My ultimate goal is to be able to display a list of lookup items as a dropdown on a form.  That being said, I’m trying the approach of adding an HTML Web Resource that contains an HTML dropdown, and populating that dropdown via javascript (so that I don’t get the ‘Lookup Search’ form, especially the ‘Look for More Records’ link).

So I have two web resources: An HTML web resource, that references a javascript resource.  The HTML resource loads ClientGlobalContext.js.aspx first, and this works fine.

But once it loads the custom javascript web resource, nothing in the body tag is displayed.   If I comment out the reference to the javascript file, it loads fine.  I’ve even paired down both web resources so that they don’t do any real work, in an effort to try to get them to load.

Here is my HTML web resource:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title></title>
        <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
        <script src="../WebResources/new_lookupdrowndown.js" type="text/javascript"/>
         <link href="/_common/styles/fonts.css.aspx?lcid=1033" rel="stylesheet" type="text/css"/>  
        <link href="/_common/styles/global.css.aspx?lcid=1033" rel="stylesheet" type="text/css"/>  
        <link href="/_common/styles/select.css.aspx?lcid=1033" rel="stylesheet" type="text/css"/>  
    </head>
    <body>
	Test Page
    </body>
</html>

Here's the javascript web resource (just one of the utility functions that I'll eventually need):

function SetLookupValueToNull(fieldName) {
    if (fieldName != null) {
        window.parent.Xrm.Page.getAttribute(fieldName).setValue(null);
    }
}

I see in the Network tab of the browser dev tools that the custom javascript is loaded correctly (no 404).
I do see an error in the Console, but it's different for each browser. Here's what I see in Chrome:

Learning Path Load Script callback error: TypeError: Cannot read property 'Util' of undefined

I don't see this error when I comment out the customer javascript reference.

Any ideas what could be happening here? This could be a cross-domain issue, I guess, but I'm not sure how to handle it.
Another option would be to embed the script code in the HTML page; that feels wrong, but I've had several problems getting to this point, and I really need to get this finished.

Thanks in advance for any help.



Source link

Leave a reply

Please enter your comment!
Please enter your name here