Use the code template from here
If you need to close the queueitem after creating a case from an email, here you go with the code
target is of type entity "email"
If you need to close the queueitem after creating a case from an email, here you go with the code
target is of type entity "email"
Code:
if (target.Contains("regardingobjectid")) { EntityReference _object = (EntityReference)target["regardingobjectid"]; if (_object.LogicalName == "incident") { CloseQueueItem(_object.Id, service); } }
Code:
public static bool CloseQueueItem(Guid _sourceId, IOrganizationService service) { Guid _queueItemId = Guid.Empty; bool _queueItemClosed = false; ConditionExpression ent_ce1 = new ConditionExpression("objectid", ConditionOperator.Equal, _sourceId); ConditionExpression ent_ce2 = new ConditionExpression("statecode", ConditionOperator.Equal, 0); FilterExpression ent_fe = new FilterExpression(LogicalOperator.And); ent_fe.AddCondition(ent_ce1); ent_fe.AddCondition(ent_ce2); QueryExpression ent_qe = new QueryExpression(); ent_qe.EntityName = "queueitem"; ent_qe.Criteria = ent_fe; ent_qe.ColumnSet = new ColumnSet("queueitemid", "queueid", "objectid"); ent_qe.PageInfo.ReturnTotalRecordCount = true; EntityCollection ent_coll = service.RetrieveMultiple(ent_qe); if (ent_coll.Entities.Count > 0) { foreach (Entity _queueItem in ent_coll.Entities) { EntityReference enRef = (EntityReference)_queueItem["objectid"]; PluginHelper.SetState(_queueItem.LogicalName, _queueItem.Id, 1, 2, service); } _queueItemClosed = true; } return _queueItemClosed; }
No comments:
Post a Comment