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)

How to use javascript document.createElement, document.body, $(document) in HTML Webresouce as per Microsoft CRM Code Review?

(0) ShareShare
ReportReport
Posted on by

First of all, I am not regular blogger and I am damn confuse. Please guide me if my question is not up to the mark. I will try to improve.

I have submitted a Microsoft CRM PlugIn of Microsoft Code Review. I am new in Javascript. I got few suggestion from their side specially in Java Script.

Some of them are following. Can any body please guide me? That will be greatly helpful:

1- Microsoft Comments: 'document.createElement('script')' calls a document object function of the CRM document object model (DOM) directly. This technique is unsupported in all versions of Dynamics CRM. Remove or replace with a supported API provided in the Xrm.Page client object model. - Comments: 'document.body' calls a document object property of the CRM document object model (DOM) directly. This technique is unsupported in all versions of Dynamics CRM. Remove or replace with a supported API provided in the Xrm.Page client object model.

My code in .JS (as webresouce) file:

var NewScript = document.createElement('script')
NewScript.src = "ajax.googleapis.com/.../jquery.min.js"
document.body.appendChild(NewScript);

2-Module: sm_ordertest.htm.scripts

Statement: $(document)
Source: .../WebResources/ordertest.htm.scripts.js
Line: 5

Microsoft Comments: '$(document)' calls a global DOM-related function of the CRM document object model (DOM) directly. This technique is unsupported in all versions of Dynamics CRM. Remove or replace with a supported API provided in the Xrm.Page client object model.

My code in .HTML (as webresource) file:

<script type="text/javascript">
    $(document).ready(function () {
    //code
    }
</script>

3-Module: sm_ManageSingleProduct.htm.scripts

Statement: $("#trnamesuccess")
Source: .../WebResources/SingleProduct.htm.scripts.js
Line: 109

Microsoft Comments: '$('#btnsave')' calls a global DOM-related function of the CRM document object model (DOM) directly. This technique is unsupported in all versions of Dynamics CRM. Remove or replace with a supported API provided in the Xrm.Page client object model.

My code in .HTML (as webresource) file:

<script type="text/javascript">
    function enableButton() {
        $('#btnsave').attr('disabled', false);
    }
</script>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    You should start be reading through the SDK on using the supported JavaScript methods: 

    https://msdn.microsoft.com/en-us/library/gg328255.aspx

    And also how to use HTML web resources:

    https://msdn.microsoft.com/en-us/library/gg309473.aspx

  • Community Member Profile Picture
    on at

    Thanks Jason. I know I must read this before start the development. I am running out of time, so just read overview of it. I have done with all other corrections. But I just don't get solution of above 3 points.

    Can you please suggest me alternate of all 3 points of question?

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