Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How I call Web Api on main function?

Posted on by 775

hello,

       I want to call web api on main function of my calendar but dont understanding how does not work ? help for call web api by json in javascript..

Thanx..

*This post is locked for comments

  • Verified answer
    kiran_rajput Profile Picture
    kiran_rajput 775 on at
    RE: How I call Web Api on main function?

    Thank you Alex

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: How I call Web Api on main function?

    Check your filter:

    filter=createdon eq 2017-09-27T05:22:52Z

    You are asking Web API for the phone calls that were created on the 27th of September, exactly at 05:22:52

  • Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: How I call Web Api on main function?

    It's not returning anything or it just throws some error?

  • Verified answer
    kiran_rajput Profile Picture
    kiran_rajput 775 on at
    RE: How I call Web Api on main function?

    I want display records of activity entity such as if phone calls actual start 2017-09-23 and actualend 2017-09-24 then it will show on custom calendar by web api.

    function retrieveEntityActivity()

      {

    var clientURL=window.parent.Xrm.Page.context.getClientUrl();

       var req = new XMLHttpRequest();

       req.open("GET", clientURL + "/api/data/v8.2/phonecalls?$select=subject,phonenumber,actualstart,actualend,activitytypecode&$filter=createdon eq 2017-09-27T05:22:52Z", true);

       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.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");

       req.setRequestHeader("Prefer", "odata.maxpagesize=10");

       req.onreadystatechange = function ()

    {

           if (this.readyState === 4)

    {

               req.onreadystatechange = null;

               if (this.status === 200)

    {

                   var results = JSON.parse(this.response);

                   var resultData=results.value;

    for (var j = 0; j < resData.length; j++)

                   {

                var subject = resultData[j]["subject"];

                    var activitytypecode = resultData[j]["activitytypecode"];

                var createdon = resultData[j]["createdon"];

                var actualstart=resultData[j]["actualstart"];

                    var actualend=resultData[j]["actualend"];

                   }

    }

               else

    {

                   alert(this.statusText);

               }

           }

       };

       req.send();

    }

    Its my API , so How i call on my custom calendar to display records dynamically

  • Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: How I call Web Api on main function?

    Can you be more precise where you want to trigger your javascript function and example of web API call would help us to identify the problem too.

  • Verified answer
    ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: How I call Web Api on main function?

    Have you tried using David Yack's framework - github.com/.../Xrm.Tools.CRMWebAPI

    Hope this helps

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans