+ Start a Discussion
RomyRomy 

How to Assign Old owner to case when someone try to assign new owner to case ?

Here I am preventing the case owner to be changed..by using triggers...by writing --  cc[0].OwnerId = Trigger.old[0].OwnerId;   

 

After this Even in Debug Logs, Old and new owner Id's are same and are equal to that of  Trigger.Old[0].OwnerId  ..... but In page layout after saving the case...Case Owner has te name of new owner?????

 

Can you suggest how to prevent the case owner from being changed ....And I don't want to through an error message.

 

if(!WGQueueName.isEmpty()){ System.Debug('Inside WGQueueName not Empty'); assignedCaseMetric = new Case_Metrics__c (Case__c = caseID, Workgroup__c = WGQueueName[0].Name, CS_Case_Status__c = 'To Queue', Assigned_Date_Time__c = datetime.now()); System.Debug('WorkGroup Name: ' +WGQueueName[0].Name +'\t WG Queue Name: ' +WGQueueName[0].Workgroup_Queue__c); if(assignedCaseMetric != Null){ Insert assignedCaseMetric; }

cc[0].CS_Workgroup__c = WGQueueName[0].Id; cc[0].Workgoup_Email2__c = WGQueueName[0].Workgroup_Email__c; }

else{ System.Debug('Inside else when WGQueueName is Empty'); QueueSobject[] qq =[Select q.SobjectType, q.Queue.Name, q.QueueId, q.Id From QueueSobject q Where SobjectType = 'Case' AND q.QueueId =: Trigger.old[0].OwnerId]; System.Debug('Old Owner ID: ' +Trigger.old[0].OwnerId +'\t New Owner Id: ' +Trigger.new[0].OwnerId); cc[0].OwnerId = qq[0].QueueId;

System.Debug('Old Owner ID: ' +cc[0].OwnerId +'\t New Owner Id: ' +Trigger.new[0].OwnerId); } System.Debug('Old Owner ID: ' +cc[0].OwnerId +'\t New Owner Id: ' +Trigger.new[0].OwnerId); Debug Logs: 20100225032713.945:Trigger.UpdateCaseMetric: line 149, column 25: Inside else when WGQueueName is Empty 20100225032713.945:Trigger.UpdateCaseMetric: line 150, column 44: SOQL query with 1 row finished in 12 ms 20100225032713.945:Trigger.UpdateCaseMetric: line 154, column 29: Old Owner ID: 00G70000001CrsvEAC New Owner Id: 00G70000001U0D4EAK 20100225032713.945:Trigger.UpdateCaseMetric: line 156, column 29: Old Owner ID: 00G70000001CrsvEAC New Owner Id: 00G70000001CrsvEAC 20100225032713.945:Trigger.UpdateCaseMetric: line 160, column 29: Old Owner ID: 00G70000001CrsvEAC New Owner Id: 00G70000001CrsvEAC

paul-lmipaul-lmi
i'd recommend just a standard validation rule for this instead of a trigger.
RomyRomy
Sorry but I  don't want to through an error message...that's not my requirement...and I need to implement with trigger only..Can you suggest how to prevent the case owner from being changed ....And I don't want to through an error message using validation rules. I just need if some one change the owner and save the case...the case will be saved with old owner not the new owner