Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

How to call Namespaced javascript function

$
0
0

Hi,

I have created javascript file with the namespace pattern, code is as below...

var MyNamespace = MyNamespace || {};

MyNamespace = function (Xrm, $, undefined) // Start namespace definition

{
"use strict";

// Start of private functions
var _MyTestFunction = function ()
{
alert("Works fine....");
}

// Start of public variables and functions return object
return {

//// Start of public functions
MyTestFunction: _MyTestFunction,
//// End of public functions
}
}(window.Xrm, jQuery);

From the normal web application We call the function with the following syntax.

MyNamespace.MyTestFunction

But its not working from the CRM form. When I called it onload form event. It throws following error.

Script Error
One of the scripts for this record has caused an error. For more details, download the log file.
TypeError: Object doesn't support property or method 'MyTestFunction' at eval code (eval code:1:1)

How can we call this function from the CRM form properties? Please help me if I am missing anything.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>