• Nisha M 6
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have the following requirement.
When a case is created, it is submitted for approval.After getting an intermediate approval, the case owner should be changed to a queue.I could do this using workflow.Now comes the real issue.The Case object is private .Hence the creator(initial owner) can't even read the case which shouldn't be the case.
What I want is the ownership should be given to the queue but creator should be able to read the case.Giving access to a particular role, group etc wont work as anyone in service team can create a case and only that person has to be given read permission on that case record after changing ownership.
Plz help!!
Thanks, Nisha
Hi,
I was trying out a simple trigger on Case Object.There is a field Hiring_Manager__c (looks up to User) in Case .On update or insert of a case, this field has to be populated with the Case Owner's Manager.I created the trigger as follows.It is not bulkified as I was just trying out for a single record.
I could see the value getting populated correctly in debug statements.But it is not updated on the record.

trigger HiringManagerupdate_case on Case (before insert,before update) {
    Case updatedCaseRec= [select id,ownerId,Hiring_Manager__c,CaseNumber from case where id in :Trigger.new];
      system.debug('Case Number'+updatedCaseRec.CaseNumber);
      system.debug('Manager before updation'+updatedCaseRec.Hiring_Manager__c);
    Map<id,String> mapOwnerMgr=new Map<id,String>();
    try{
       User caseOwner = [Select Id,Name, ManagerId, Manager.Email From User Where Id = :updatedCaseRec.ownerId];
                updatedCaseRec.Hiring_Manager__c=caseOwner.ManagerId;
                
    }
    Catch(DMLException de){
        system.debug('Could not find Manager');
    }
    system.debug('Manager'+updatedCaseRec.Hiring_Manager__c);
 
}
Hi,
I was trying out a simple trigger on Case Object.There is a field Hiring_Manager__c (looks up to User) in Case .On update or insert of a case, this field has to be populated with the Case Owner's Manager.I created the trigger as follows.It is not bulkified as I was just trying out for a single record.
I could see the value getting populated correctly in debug statements.But it is not updated on the record.

trigger HiringManagerupdate_case on Case (before insert,before update) {
    Case updatedCaseRec= [select id,ownerId,Hiring_Manager__c,CaseNumber from case where id in :Trigger.new];
      system.debug('Case Number'+updatedCaseRec.CaseNumber);
      system.debug('Manager before updation'+updatedCaseRec.Hiring_Manager__c);
    Map<id,String> mapOwnerMgr=new Map<id,String>();
    try{
       User caseOwner = [Select Id,Name, ManagerId, Manager.Email From User Where Id = :updatedCaseRec.ownerId];
                updatedCaseRec.Hiring_Manager__c=caseOwner.ManagerId;
                
    }
    Catch(DMLException de){
        system.debug('Could not find Manager');
    }
    system.debug('Manager'+updatedCaseRec.Hiring_Manager__c);
 
}