3

I'm trying to update a field on a phone call entity, then close it. Current to do so as far as I can tell, takes two calls. But this is painfully slow as it's taken 30 minutes to process 60 phone calls and I have around 200,000 to do. Is there a way to combine both into one call?

Here's my current code -

foreach (phonecall phonepointer in _businessEntityCollection.BusinessEntities.Cast<phonecall>()
     .Where(phonepointer => phonepointer.statecode.Value == PhoneCallState.Open))
{
  //Update fiserv_contactstatus value
  phonepointer.fiserv_contactstatus = Picklist;
  crmService.Update(phonepointer);

  //Cancel activity
  setStatePhoneCallRequest.PhoneCallState = PhoneCallState.Canceled;
  setStatePhoneCallRequest.PhoneCallStatus = 200011;
  setStatePhoneCallRequest.EntityId = phonepointer.activityid.Value;

  crmService.Execute(setStatePhoneCallRequest);
}
Patrick
  • 17,669
  • 6
  • 70
  • 85
Merds
  • 53
  • 10
  • for some reason it formatted the code funny, but there's a Update call, then a Execute call. – Merds Dec 21 '11 at 17:06
  • 1
    Are there any other plugins around this entities? 30 min is way too much. – ccellar Dec 21 '11 at 17:13
  • I've tried to change the update method to use and updaterequest of the TargetUpdatePhoneCall, which sped it up some, but I'm avg about 15 secs per closing which with the 200,000 I have in the system to close means 34 solid days of running. If I can't speed this up, I'm tempted to do straight SQL updates. That'd take a matter of seconds, not a month. – Merds Dec 21 '11 at 18:04
  • Ok, I've done a bunch more and set timers to see how long each part is taking. This time it appears the avg over a time period is about 7.5 seconds for each part so total around 15 seconds. That still seems very high to me. – Merds Dec 21 '11 at 20:24

1 Answers1

1

Unfortunately, there's little you can do.

You COULD try and use the new SDK and the XRM context (strongly typed classes) to batch-update the phone call entities (this should be faster), but you'll still need to use the old-fashioned CrmService to actually change the state of each entity, one by one.

EDIT: You could also directly change the state of the entities in the database, but this should be your last resort, as manual changes to the CRM DB are unsupported and dangerous.

Seriously, last resort! No, I'm NOT joking!

MBender
  • 5,395
  • 1
  • 42
  • 69