We are using custom case page in Lightning with Lightning Component. On insert on case, it is going to default case Queue.

On update on case it is not going to other queue according to assignment rule.

Note: We have already written the code logic which is still not working

    AssignmentRule AR = new AssignmentRule();
    AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];

    Database.DMLOptions dmlOpts = new Database.DMLOptions();
    dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
    if(dmlcontext == 'insert'){
        Id devRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Case Support').getRecordTypeId();
        CaseInstance.recordTypeId = devRecordTypeId;
        insert CaseInstance;
        resultVal = CaseInstance.id;
    else if(dmlcontext == 'update'){
        update CaseInstance;
        resultVal = 'case updated';
return resultVal;

Am looking for any other alternative.

1 Answer 1


SObject setOptions does not work. Instead, use the alternative Database.insert/update(record, DMLOptions) version:

Database.insert(CaseInstance, dmlOpts);
Database.update(CaseInstance, dmlOpts);

Coincidentally, you can save a query by choosing to use the Default Rule (assuming you set your rule as default):

dmlOpts.AssignmentRuleHeader.useDefaultRule = true;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .