Skip to main content

Notifications

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

  • Verified answer
    Silvio J Souza Profile Picture
    30 on at
    RE: CRM Organisation Service

    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.

  • Suggested answer
    Swetha Poojary Salaskar Profile Picture
    326 on at
    RE: CRM Organisation Service

    Hi Shalu

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

  • Shalu Malik Profile Picture
    on at
    RE: CRM Organisation Service

    Thank You Swetha for your answer.

  • Verified answer
    Swetha Poojary Salaskar Profile Picture
    326 on at
    RE: CRM Organisation Service

    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
    RE: CRM Organisation Service

    Hi Akhil,

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

    Thanks

  • Akhil101 Profile Picture
    432 on at
    RE: CRM Organisation Service

    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
    RE: CRM Organisation Service

    I was expecting this question.

    I need to host it outside.

  • Suggested answer
    Akhil101 Profile Picture
    432 on at
    RE: CRM Organisation Service

    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

  • Swetha Poojary Salaskar Profile Picture
    326 on at
    RE: CRM Organisation Service

    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?

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans