I have two fields avd_starttime and avd_stoptime. I am writing the below code to update the avd_stoptime field with datetime.now. But I am getting the error as "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."..PLease tell me where I am going wrong??
internal static bool StopAht(ICrmContext context)
{
QueryExpression exp = new QueryExpression(avd_agenthandlingtime.EntityLogicalName);
exp.NoLock = true;
exp.ColumnSet.AddColumn(XrmAttributes.AgentHandlingTime.Id);
exp.ColumnSet.AddColumn(XrmAttributes.AgentHandlingTime.StopTime);
ConditionExpression CondOppId = new ConditionExpression();
CondOppId.AttributeName = "avd_StopTime";
CondOppId.Operator = ConditionOperator.Null;
string timerId = XrmAttributes.AgentHandlingTime.Id;
var coll = context.OrganizationService.RetrieveMultiple(exp);
if (coll != null && coll.Entities != null && coll.Entities.Count > 0)
{
foreach (var ent in coll.Entities)
{
avd_agenthandlingtime stopTimer = new avd_agenthandlingtime()
{
Id = new Guid(timerId),
avd_StopTime = DateTime.Now
};
context.AdminUpdate(stopTimer);
}
}
return true;
}