On Case Object,we have 2 record types PreSales & Delivery Support. PreSales Users can access only PreSales Record Type & Delivery Support User can access Delivery Support Record Type only.

In one of the user story requirement,our client wants Business User to change the record type functionlity Business User. So if I am a PreSales User,I can change the record type of Case to Delivery Support even though I do not have Delivery Support Record Type Access & vice versa.

To achive this functionlity I have written a below code where I created a picklist field and based on Picklist field value I am assigning record type on Before Insert Trigger.

public void changeRecordType(List<SObject> newItems,Map<Id,SObject> oldItems){
        system.debug('Entering CasetTriggerHandler:changeRecordType() Function');

            Map<String,Id> recordTypeMap=new Map <String,Id>();
            Map<String,Id> queueMap=new Map <String,Id>();
            for(RecordType rt: [Select DeveloperName, Id From RecordType Where sObjectType = 'Case' AND DeveloperName<>'Case']){
            for(Group grp:[SELECT DeveloperName,Id,Name,Type FROM Group where Type='Queue']){
            for(SObject newObj :newItems) {
                Case newCaseObj = (Case)newObj;
                Case oldCaseObj = (Case)oldItems.get(newCaseObj.Id);
                if(!recordTypeMap.isEmpty() && !queueMap.isEmpty() && !newCaseObj.Change_Case_RecordType_To__c.equals(oldCaseObj.Change_Case_RecordType_To__c)){
                    system.debug('Change Case Record Type is different');
                    if(newCaseObj.Change_Case_RecordType_To__c=='PreSales' && newCaseObj.Case_RecordType_Dev_Name__c=='Delivery_Support_Case'){
                        system.debug('Delivery to PreSales');
                        newCaseObj.OwnerId = queueMap.get('PreSales_Case_Queues');
                    else if(newCaseObj.Change_Case_RecordType_To__c=='Delivery Support' &&  newCaseObj.Case_RecordType_Dev_Name__c=='PreSales_Support_Case')
                        system.debug('PreSales to Delivery');
                        newCaseObj.OwnerId = queueMap.get('Delivery_Case_Queues');




Above code is working as expected.

When I change the record type of the Case below is the behavior in Classic & Lightning:


enter image description here

It display valid message


enter image description here

It does not display proper message.Instead the record is visible in read only mode.

If I want consistent behavior here.How can get rid of this in lightning view?

I am wondering If I can navigate to List view of Case after changing the Record type that could resolve my problem. But Page reference works only for VF Page scenario & in my functionlity I am using Standard Page layout and Button.

Can someone please suggest what needs to be done in such situation.


1 Answer 1


Generally, this seems like unexpected behaviour - so I would open a support case.

As for your goal:

Build a custom lightning component for lightning to achieve this - from there you have full control over navigation.

In the Trigger you could check for the user's context (i.e. Lightning or Classic) by using getUiThemeDisplayed() and only run the parts you already coded for people who are not working in Lightning.

  • But In my code, I do not written any such part which is not woring in lighting.I am only changing record type and Change the case owner to queue and it is currently on Spring 18
    – SFDCDJ
    Jan 9, 2018 at 14:18
  • As I said, this seems to be a bug - hence the suggestion to open a case. I believe Lightning should redirect you after the update instead of leaving a read only version open. Jan 9, 2018 at 14:20
  • Thanks for suggestion I will try to open a Case for this.Unfortunately we dont have premier support hence Salesforce wont help in Coding.Need to check for the Same.
    – SFDCDJ
    Jan 9, 2018 at 14:22
  • Yes, I know the feeling. Couldn't you reproduce the same by configuration: Open your case in classic, change the recordtype in another tab/window, hit refresh in the original tab. Do the same for lightning - I assume you will see the same behaviour. Jan 9, 2018 at 14:30
  • Tried.In lighting the behavior is same.it displays the record in read only mode
    – SFDCDJ
    Jan 9, 2018 at 14:37

You must log in to answer this question.

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