So the issues turns out to be the DML options.
In order for e-mails to get sent - even from Assignment Rules, the DML option has to be updated:
dmlOpts.EmailHeader.TriggerUserEmail = true;
Otherwise it will ignore any email trying to be sent internally that is not called by apex directly.
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:
- Email-to-Case, Origin = 'Email'
- Web-to-Case, Origin = 'Web'
- 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.
Best Answer
you need to add another filter which can stop your assignment rule to fire everytime. For example, you donot want to fire this rule when case owner changes but project__c is true, change your assignment rule criteria to "Formula evaluates to true" and use below:
If you want to run your assignment rule only during creation of case use this formula..
ISNEW() && Project__c