viernes, 13 de septiembre de 2013

CRM 4.0 - Hacer un borrado en masa a partir de una query

FetchXmlToQueryExpressionRequest fetchqueryreq = new FetchXmlToQueryExpressionRequest();
fetchqueryreq.FetchXml = (string)fetch;
FetchXmlToQueryExpressionResponse qe = (FetchXmlToQueryExpressionResponse)crmService.Execute(fetchqueryreq);

BulkDeleteRequest BDreq = new BulkDeleteRequest();
BDreq.JobName = "Elimina todos los Codigos Postales";
BDreq.QuerySet = new QueryBase[] { qe.Query };
BDreq.SendEmailNotification = false;
BDreq.StartDateTime = new CrmDateTime();
BDreq.StartDateTime.Value = DateTime.Now.ToString("s");
BDreq.ToRecipients = new Guid[0];
BDreq.CCRecipients = new Guid[0];
BDreq.RecurrencePattern = string.Empty;
BulkDeleteResponse BDresp = (BulkDeleteResponse)crmService.Execute(BDreq);

No hay comentarios:

Publicar un comentario