When I trigger plugin on BookingDates Create
indeed to update some filed related to BookingSetups
and use that Plugin
IOrganizationService Service = serviceProxy;
Entity entity = new Entity("msdyn_agreementbookingdate");
var fetchXmlDates = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXmlDates += "<entity name='msdyn_agreementbookingdate'>";
fetchXmlDates += "<attribute name='msdyn_bookingsetup' />";
fetchXmlDates += "<attribute name='msdyn_bookingdate' />";
fetchXmlDates += "<attribute name='msdyn_agreement' />";
fetchXmlDates += "<attribute name='msdyn_agreementbookingdateid' />";
fetchXmlDates += "<order attribute='msdyn_bookingdate' descending='true' />";
fetchXmlDates += "<filter type='and'>";
fetchXmlDates += "<condition attribute='msdyn_agreement' operator='eq' uitype='msdyn_agreement' value='368093c6-a856-e911-a964-000d3a4647a5' />";
fetchXmlDates += "<condition attribute='msdyn_agreementbookingdateid' operator='ne' value='" + entity.Id + "' />";
fetchXmlDates += "</filter>";
fetchXmlDates += "<link-entity name='msdyn_agreementbookingsetup' from='msdyn_agreementbookingsetupid' to='msdyn_bookingsetup' alias='bookRec'>";
fetchXmlDates += "<attribute name='new_bookingrecurring' />";
fetchXmlDates += "<attribute name='msdyn_agreementbookingsetupid' />";
fetchXmlDates += "<attribute name='new_customerasset' />";
fetchXmlDates += "<filter type='and'>";
fetchXmlDates += "<condition attribute='new_bookingrecurring' operator='not-null' />";
fetchXmlDates += "</filter>";
fetchXmlDates += "</link-entity>";
fetchXmlDates += "</entity>";
fetchXmlDates += "</fetch>";
EntityCollection resultDates = Service.RetrieveMultiple(new FetchExpression(fetchXmlDates));
var multipleRequest = new ExecuteMultipleRequest()
{
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = false,
ReturnResponses = true
},
Requests = new OrganizationRequestCollection()
};
foreach (Entity c in resultDates.Entities)
{
var Bookingsetupidfetch = c.Attributes["msdyn_agreementbookingsetupid"];
var BookingsetupidEntity = entity.Attributes["msdyn_bookingsetup"];
if (Bookingsetupidfetch == BookingsetupidEntity)
{
//Console.WriteLine("BookingDate: {0}", c.Attributes["new_customerasset"]);
UpdateRequest updateRequest = new UpdateRequest { Target = c };
multipleRequest.Requests.Add(updateRequest);
c.Attributes["new_customerasset"] = c.Attributes["new_customerasset"];
count++;
}
}
ExecuteMultipleResponse multipleResponse = (ExecuteMultipleResponse)Service.Execute(multipleRequest);
and that error appears
but when i use Static GUID Update operation is Work successfully done
regardes