Reputation: 60741
Is it possible to add a resource (user / facility) to an serviceappointment?
Here's my record to which I want to add resources:
var serviceAppointment = this.organizationService.Retrieve(
"serviceappointment",
serviceActivityGuid,
new ColumnSet(true));
I have a list of resources:
{
"ListOfResourceIds": [
{
"partyid": "9CDC2C51-6417-4550-A0FE-D825EE75D333"
},
{
"partyid": "9CDC2C51-6417-4550-A0FE-D825EE75D044"
}
]
}
How would I add these resources to ServiceAppointment above?
I suspect that after adding them, I would call:
organizationService.Update(serviceAppointment);
Upvotes: 0
Views: 53
Reputation: 2980
Resources are of the type ActivityParty (SystemUser). To update the service appointment, get the corresponding system user ids of the resources:
var serviceAppointment = organizationService.Retrieve(
"serviceappointment",
serviceActivityGuid,
new ColumnSet(true));
var updateServiceAppointment = new Entity("serviceappointment")
{
Id = serviceAppointment.Id
};
updateServiceAppointment["resources"] = new[]
{
new ActivityParty()
{
PartyId = new CrmEntityReference("systemuser", correspondingSystemUserId)
}
};
organizationService.Update(updateServiceAppointment);
Upvotes: 1