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)

CRM Organisation Service

(0) ShareShare
ReportReport
Posted on by

Hi Everyone,

I have a requirement to call CRM organisation service using javascript.

Actually, I have to create a HTML page and through it, I want to perform some action in CRM. That's why I want to call Organisation service using javascript.

Is it possible? If yes, can anyone suggest me a way.

Thank You 

*This post is locked for comments

I have the same question (0)
  • Swetha Poojary Salaskar Profile Picture
    326 on at

    Hi Shalu,

    Can you details me more about the requirement ? Html page will be deployed with CRM as web resource or it will be hosted outside?

  • Suggested answer
    Akhil101 Profile Picture
    432 on at

    Hi Shalu,

    If you are trying to access context information you can always add the below reference to your html web resource.  

    <script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>

    Also if you want to make any changes to CRM entity records then always use Web Api. Please see the code below.

    <script>

    function Update(accountID){

    var entity = {};

    entity.accountcategorycode = 1;

    var req = new XMLHttpRequest();

    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts("+accountID+")", false);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204) {

               //Success - No Return Data - Do Something

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(entity));

    }

    </script>

    Import REST Builder Solution to your CRM organization and generate the above WEB API Request.

    github.com/.../CRMRESTBuilder

    Regards

    AKHIL R

  • Shalu Malik Profile Picture
    on at

    I was expecting this question.

    I need to host it outside.

  • Akhil101 Profile Picture
    432 on at

    if you are not creating a web resource then are you developing any website and trying to connect to CRM from it?

    Regards

    AKHIL R

  • Shalu Malik Profile Picture
    on at

    Hi Akhil,

    I want to communicate with CRM through the html page using javascript and I need to host it somewhere.

    Thanks

  • Verified answer
    Swetha Poojary Salaskar Profile Picture
    326 on at

    HI Shalu,

    For calling CRM organization service your applicaation need to be authenticated which is not possible Using only javascript. You need to have Server side code. Either you use MVC application or normal web application

  • Shalu Malik Profile Picture
    on at

    Thank You Swetha for your answer.

  • Suggested answer
    Swetha Poojary Salaskar Profile Picture
    326 on at

    Hi Shalu

    Hope my Answer  helps! I'd appreciate if you'd marking my Answering your question.

  • Verified answer
    Silvio J Souza Profile Picture
    30 on at

    Hi Shalu,

    For html/javascript use web api. On Sdk we have samples about this.

    For Asp.net code you can do a reference to SDK libraries and call organization service. See sample code in C# on sdk.

    Silvio.

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