Bvrce
Bvrce

Reputation: 2170

Form Event to Call JavaScript Function in Namespace

How can a function in a namespace be called from a form event? I have tried

accountLib.accountType.showType

and

accountLib.accountType.showType()

in the onload event, but it does not work.
This is the code:

/// <reference path="Scripts/XrmPageTemplate.js" />
if (typeof (accountLib) == "undefined") {
accountLib == {}; // namespace
}
accountLib.accountType = {
    showType: function () {
        alert("RINNING");
    }
};

Upvotes: 0

Views: 433

Answers (1)

Mattyod
Mattyod

Reputation: 1427

You have a double == when you try to create the accountLib object. This a comparative operator and will not set the variable to be an object. If you check your console it probable throws an error on the line: accountLib.accountType = {

try:

if (!accountLib) {
    accountLib = {}; // namespace
}

Upvotes: 3

Related Questions