[SalesForce] Suppress Case Assignment Rule from case created by LiveHelpNow Chat application

I'm trying to Suppress the Case assignment rule when case get create by LiveHelpNow Chat App. Also though the same Trigger i'm trying to assign the case to the LiveHelpNow Agent Name to i've captured into a Case.Case_Owner__c custom field and matched against the Salesforce slandered User object. Unfortunately i'm unable to disable the case assignment rule and case keeps getting assigned to The Queue by the assignment rule. I need the Case assignment rule because we also have web to case that we like those cases to be assigned to a Queue, so turning off Case assignment rule is off the table. Any Help Please.

trigger LiveHelpReAssign on Case (before insert)
{
    Map<String, Id> ownerUser = new Map<String, Id>();
    for(Case record : Trigger.new)
    {
        if(record.Case_owner__c != record.Owner.Name)
        {
            ownerUser.put(record.Case_owner__c, null);
        }
    }
    for(User record:[select Name 
                     From User 
                     Where Name IN :ownerUser.keyset()]) 
    {
        ownerUser.put(record.Name, record.Id);
    }
    for(Case record : Trigger.new)
    {
        Database.DMLOptions dmo = new Database.DMLOptions();
        dmo.AssignmentRuleHeader.useDefaultRule = false;
        record.OwnerId = ownerUser.get(record.Case_owner__c);
        record.SetOptions(dmo);
    }
}

enter image description here

Best Answer

There are different ways we can create cases and those can be handled and properly assigned to the queue or himself based on assignment rules.

You can define Case Origin picklist values as follows:

  1. Email-to-Case, Origin = 'Email'
  2. Web-to-Case, Origin = 'Web'
  3. Live Agent, Origin = 'Chat'

Also, you can define different recordTypes based on criteria (including Origin).

In the Case assignment rule, you can verify Origin or recordtype or other criteria and assign the cases to different owner.

If no criteria is matching, then you can assign the Case to the same user/Admin/specific user/queue.

Updating answer for userDefaultRule

If specified as true for a case or lead, the system uses the default (active) assignment rule for the case or lead. If specified, do not specify an assignmentRuleId.

Usage

If there are no assignment rules in the organization, in API version 29.0 and earlier, creating a case or lead with useDefaultRule set to true results in the case or lead being assigned to the predefined default owner. In API version 30.0 and later, the case or lead is unassigned and doesn't get assigned to the default owner.

Workaround

Do not stop assignment rule. Rather than using trigger, you can use process builder to update the case owner for Chat origin cases. Process builder runs after Case assignment rules, Hopefully it helps.

Related Topic