Hello - I'd like to add some code to ensure that CRM doesn't send duplicate emails, for example, 2 identical approval request emails to the same approver. The following method exists in the codebase to route requests:
public static void RouteTo(IOrganizationService serviceProvider, Guid requestId, Guid queueId)
{
var addToSourceQueue = new AddToQueueRequest
{
DestinationQueueId = queueId,
Target = new EntityReference(Incident.EntityLogicalName, requestId)
};
serviceProvider.Execute(addToSourceQueue);
}
Is there a way to modify this code to prevent duplicate email requests? For example, could I add some code like this to the top of the method above?:
//if requestid is already in queue then return
//not sure how to use columnSet???
var entity = serviceProvider.Retrieve(Incident.EntityLogicalName, queueId, columnSet);
if(entity != null) return;