Hi All,
I am trying to update subject value of Case entity on all records. Using multiple request to bulk update records. However, for every 500 records i get only 20-30 responses and the same are the ones being updated on CRM. Could you help me as to what might the issue be? Using below code to update.
int entitiesCount = rawData.Entities.Count;
int count = 0;
while(true)
{
// Create an ExecuteMultipleRequest object.
var multipleRequest = new ExecuteMultipleRequest()
{
// Assign settings that define execution behavior: continue on error, return responses.
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = false,
ReturnResponses = true
},
// Create an empty organization request collection.
Requests = new OrganizationRequestCollection()
};
//rawData contains Case entity data. Looping through 500 records
var items = rawData.Entities.Skip(count * 500).Take(500);
items.ToList().ForEach(item =>
{
UpdateRequest updateRequest = new UpdateRequest { Target = item };
item.Attributes["subjectid"] = new EntityReference("subject", "Guid value");
multipleRequest.Requests.Add(updateRequest);
});
// Execute all the requests in the request collection using a single web method call.
ExecuteMultipleResponse multipleResponse = (ExecuteMultipleResponse)service.Execute(multipleRequest);
if (count * 500 > entitiesCount)
{
Console.WriteLine("Number of processed records - " + count * 500);
break;
}
else
{
count += 1;
Console.WriteLine("Number of processed records - " + count * 500);
}
}