Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use javascript document.createElement, document.body, $(document) in HTML Webresouce as per Microsoft CRM Code Review?

    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?

  • Suggested answer
    jlattimer Profile Picture
    jlattimer 24,558 on at
    RE: How to use javascript document.createElement, document.body, $(document) in HTML Webresouce as per Microsoft CRM Code Review?

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans