Hi,
From the msdyn_searchresourceavailability OOB Action, based on the input parameters, i'm trying to retrieve the timeslots. I'm passing preferred resources has an input on the ResourceSpecification input but in the result timeslots i'm getting slots for all the bookable resources. Below is the code which i used in console application, please help me here why the preferred resource is not being considered?
OrganizationRequest resourceAvailabilityReq = new OrganizationRequest("msdyn_searchresourceavailability");
// Requirement
Entity newReqObject = new Entity("msdyn_resourcerequirement");
// newReqObject["msdyn_resourcerequirementid"] = new Guid("3d5b2040-3cbc-ea11-a812-000d3a239e28");
newReqObject["msdyn_fromdate"] = new DateTime(2020, 11, 27, 8, 30, 0, DateTimeKind.Local).ToUniversalTime();
newReqObject["msdyn_todate"] = new DateTime(2020, 11, 30, 17, 30, 0, DateTimeKind.Local).ToUniversalTime();
//newReqObject["msdyn_remainingduration"] = 120;
//newReqObject["msdyn_duration"] = 120;
// Settings organization systemuser
Entity travelRadius = new Entity("travelradius");
travelRadius["Value"] = 99999;
travelRadius["Unit"] = 192350001;
Entity settings = new Entity("organization");
settings["MaxResourceTravelRadius"] = travelRadius;
settings["ConsiderTravelTime"] = false;
settings["UseRealTimeResourceLocation"] = true;
settings["ConsiderSlotsWithOverlappingBooking"] = true;
settings["ConsiderSlotsWithLessThanRequiredDuration"] = true;
settings["ConsiderSlotsWithProposedBookings"] = true;
EntityCollection preferredResources = new EntityCollection();
Entity brbresource = new Entity();
brbresource.Attributes.Add("bookableresourceid", new Guid("c099b792-f9fb-ea11-a813-000d3aadc20a"));
preferredResources.Entities.Add(brbresource);
EntityCollection resourceTypes = new EntityCollection();
Entity resourceType = new Entity();
resourceType.Attributes.Add("resourcetypes", new OptionSetValue(3)); //User
resourceTypes.Entities.Add(resourceType);
Entity rescourseSpecificationEntity = new Entity("organization");
rescourseSpecificationEntity["PreferredResources"] = preferredResources;
rescourseSpecificationEntity["ResourceTypes"] = resourceTypes;
// Add to request object
resourceAvailabilityReq["Version"] = "1";
resourceAvailabilityReq["Settings"] = settings;
resourceAvailabilityReq["Requirement"] = newReqObject;
resourceAvailabilityReq["ResourceSpecification"] = rescourseSpecificationEntity;
OrganizationResponse resourceAvailabilityResp = obj.service.Execute(resourceAvailabilityReq);