Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

URS message msdyn_searchresourceaavailablity not working

(1) ShareShare
ReportReport
Posted on by 2

Hi All,

Has anyone had any luck with the subject message/api? I have able to implement this in c#. It's working and getting all the resources but when I add constraints it doesn't return anything. Tried a lot of different things but no luck.

What I am trying to achieve is to automate the booking. When a work order is created, I would like to assign the work order to the best resources based on the constraints of the work order. If there's another way, please let me know.

  • nkhemji Profile Picture
    nkhemji 2 on at
    RE: URS message msdyn_searchresourceaavailablity not working

    Hi,

    Here's the code I am using..

    dotnetfiddle.net/fXfAVW

  • CJustin Profile Picture
    CJustin 262 on at
    RE: URS message msdyn_searchresourceaavailablity not working

    Would you give us the snapshot of your code?

    That would help us to help you better.

    Have you tried putting the constraints at the right locations in the code?

    So that they return the right values.

  • eromerof Profile Picture
    eromerof 98 on at
    RE: URS message msdyn_searchresourceaavailablity not working

    Hi dyn365,

    Please, can you try this with a resource created two days ago? I think that is a Microsoft generally incident because I have the same issue in my environments.

    Thanks!

  • nkhemji Profile Picture
    nkhemji 2 on at
    RE: URS message msdyn_searchresourceaavailablity not working

    Hi Enrique

    Thanks for your reply and code.

    I have written the code and it's similar to what is mentioned here. My scenario is very simple. I have four contractors working in a different territory. I am just trying to get the contractor which is suitable for the current requirement. If I pass the requirement entity to the webapi, it returns all four contractors, however, as soon as I add territory to the requirement, nothing comes back.

    There's no other restrictions or constraint which could be blocking. I am testing this in a plain vanilla environment. When I doing a search via Schedule Board for that requirement, i am getting the correct contractor but same not happening via API.

    I couldn't find much on this API except two blogs on ms site.

    Will you be able to help further and make me understand the whole process?

  • eromerof Profile Picture
    eromerof 98 on at
    RE: URS message msdyn_searchresourceaavailablity not working

    Hi dyn365, 

    Here an example:

     OrganizationRequest req = new OrganizationRequest("msdyn_SearchResourceAvailability");
                req["Version"] = "1.0";
                var requirement = new Entity("msdyn_resourcerequirement");
                if (WorkOrderStartTime != default)
                   requirement["msdyn_fromdate"] = WorkOrderStartTime;
                if (WorkOrderEndTime != default)
                   requirement["msdyn_todate"] = WorkOrderEndTime;
                if (WorkOrderStartTime != default && WorkOrderEndTime != default)
                   requirement["msdyn_duration"] = Math.Round((WorkOrderEndTime - WorkOrderStartTime).TotalMinutes, 0);
    
                req["Requirement"] = requirement;
                var SettingsEntity = new Entity("organization");
                SettingsEntity["MovePastStartDateToCurrentDate"] = true;
                //SettingsEntity["ConsiderSlotsWithLessThanRequiredCapacity"] = true;
                req["Settings"] = SettingsEntity;
                var response = service.Execute(req); 

    I hope it helps you

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,313 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans