Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
Suggested answer

Execute multiple requests returns only fewer responses

Posted on by Microsoft Employee

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);
}
}

Categories:
  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Execute multiple requests returns only fewer responses

    Thank you Ben. Helped me solved the issue.

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: Execute multiple requests returns only fewer responses

    the content of the ExecuteMultipleResponse response especially the boolean IsFaulted property may give you a clue as to what the issue is. See msdn.microsoft.com/.../microsoft.xrm.sdk.messages.executemultipleresponse.aspx for details..

    Without looking further - don't forget you can only update active records so you need to ensure you ensure inactive (closed, completed or canceled) cases are excluded from either your initial retrieve request or checked prior to creating the update request.

    Equally executeMultiple requests are time limited (which is important to mention where a entity may have synchronous workflows triggered when a record is updated) but I suspect that isn't the case here.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,126 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans