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)

init() is undefined .

(0) ShareShare
ReportReport
Posted on by 550

I am trying to debug an Html web resource . I am getting an error init() is undefined.

I am not sure , why the error is coming and how to go about it..

I am not able to find out the error. The method definition for init() is already present..


<meta http-equiv="X-UA-Compatible" content="IE=8,chrome=1">
<!--<script src="../pcm_/js/jquery.js" type="text/javascript"></script>-->
<!--<script src="../xrmc_/js/jquery.min.js" type="text/javascript"></script>-->
<script src="code.jquery.com/.../jquery-ui.js"></script>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="../pcm_/js/json2.js" type="text/javascript"></script>
<script src="../pcm_/js/XrmServiceToolkit.min.js" type="text/javascript"></script>

<script type="text/javascript">
parent.$(document).ready(function () {
debugger;
init();
});

init = function () {

loadContractBlocks();
window.parent.Xrm.Page.getAttribute("pcm_contracttype").addOnChange(loadContractBlocks);

parent.$('#pcmCreateButton').attr('title', localizedString.CreateContractTitle[lcid]);
parent.$('#pcmCreateButton').text(localizedString.CreateContract[lcid]);
};

parent.$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
parent.$.each(a, function () {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};

console.log('create function');

var pcmCreateDocument = function () {

console.log('running function pcmCreateDocument');

if (window.parent.Xrm.Page.data.entity.getIsDirty()) {
console.log('Form is dirty. Save before create document!!!');
window.parent.Xrm.Page.data.entity.save();
} else {
console.log('Form is not dirty. Continue with document creation.');
}

var json = parent.$('form').serializeObject();

if (parent.$.isArray(json.blocks)) {
var guidsAsString = json.blocks.join(',');
callAction(guidsAsString);
}
else {
var guidAsString = json.blocks;
callAction(guidAsString);
}

};

</script>

*This post is locked for comments

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Hi,

     why are you using parent.$ ?

     I'm wondering if it's looking for the init in the parent..

  • HajiraRoshan Profile Picture
    550 on at

    Hi Alex,

    Javascript is not supporting jquery only with $ in CRM 365 .It needs parent.$ . This is my first Html web resource . Even though I tried it withoout parent , it is showing me the same error..

    I am getting $ is not defined when I try using only $

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