web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error on consuming "msdyn_RetrieveResourceAvailability"

(0) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all,

I am trying to use the OOB action "msdyn_RetrieveResourceAvailability" via JS. But getting error 'Object reference not set to an instance of an object'. Has anyone else tried this successfully/unsuccessfully? This action will return collection object. I am mentioning the code below as well as the microsoft document.

 

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/msdyn_retrieveresourceavailability?view=dynamics-ce-odata-9

All help appreciated!

function GetResource()

{

    var parameters = {};

    parameters.RealTimeMode = true;

    parameters.Duration = 1122;

    parameters.IgnoreDuration = true;

    parameters.IgnoreTravelTime = true;

    parameters.AllowOverlapping = true;

    parameters.Radius = 2211;

    parameters.StartTime = new Date("01/24/2018 04:00:00").toISOString();

    parameters.EndTime = new Date("01/30/2018 08:00:00").toISOString();

 

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/msdyn_RetrieveResourceAvailability", 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) {

            debugger;

            req.onreadystatechange = null;

            if (this.status == 200 || this.status == 204) {

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

            } else {

                Xrm.Utility.alertDialog(this.statusText);

            }

        }

    };

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

}

 

 Thank you

Regards,

AW

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I have never used this but it looks that you don't pass all the required parameters inside. Examples - Characteristics, Territories, ResourceTypes, Resources e.t.c. Check "Nullable" column from url you provided.

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Thanks Andrew for your reply. But as per snapshot below I am passing all required parameters except for optional which I think should not be the reason of this error.

    8764.Query.png

    Regards,

    AW

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Check my small article about your issue - butenko.pro/.../actions-input-parameters-and-object-reference-not-set-to-an-instance-of-an-object-exception

    So pass the fields. Even those are not marked as required.

  • Community Member Profile Picture
    on at

    Hello Abdul

    Are you able to solve this issue?

  • Suggested answer
    Community Member Profile Picture
    on at

    You need to pass the Work Order Id. For whatever reason, it is not mandatory. I made it works (no error). But it was not what I was looking for.

    I found that I needed msdyn_SearchResourceAvailability and not msdyn_RetrieveResourceAvailability.

    cloudblogs.microsoft.com/.../

    cloudblogs.microsoft.com/.../

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans