Hello, I would like to de-activate records returned in my For Each .. Can someone please assist on how to do this ?
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetch));
try { foreach (var cases in results.Entities) { if (cases.Attributes.Contains("createdon")) { DateTime newcreatedon = ((DateTime)(cases["createdon"])); if (newcreatedon != createdon) { // Start - Code for De-Activating records SetStateRequest setState = new SetStateRequest(); setState.EntityMoniker = cases.ToEntityReference(); setState.State = new OptionSetValue(); setState.State.Value = 1; setState.Status = new OptionSetValue(); setState.Status.Value = 2; SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setState);
service.Update(cases)
// End - Code for De-Activating records
}
}
}
}
Many Thanks
*This post is locked for comments