function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
udayarangareddy mekalaudayarangareddy mekala 

TRIGGERS1

Hi
  Whenever CASE record was created, update the CASE owner with a value of Account owner through trigger.plz  post the code

THANKS
RANGA
Best Answer chosen by udayarangareddy mekala
Asha KAsha K
trigger UpdatingCaseOwner on Case (after insert, after update) {

List<Case> lstCase = new List<Case>();

if(utilityclass.triggervar)
{
    for(case oCase: [select Id, OwnerId, Account.Name, Account.OwnerId,Origin,status from case where ID =: trigger.new]){
     
    utilityclass.triggervar= false;
    oCase.OwnerId = Ocase.Account.OwnerId; 
    lstCase.add(oCase);
    
    }
    
    if(lstCase.size() > 0) {
    
    Database.update(lstCase);
      
    }
   } 

Public class utilityclass{

public static Boolean triggervar= true;

}

All Answers

Asha KAsha K
trigger UpdatingCaseOwner on Case (after insert, after update) {

List<Case> lstCase = new List<Case>();

if(utilityclass.triggervar)
{
    for(case oCase: [select Id, OwnerId, Account.Name, Account.OwnerId,Origin,status from case where ID =: trigger.new]){
     
    utilityclass.triggervar= false;
    oCase.OwnerId = Ocase.Account.OwnerId; 
    lstCase.add(oCase);
    
    }
    
    if(lstCase.size() > 0) {
    
    Database.update(lstCase);
      
    }
   } 

Public class utilityclass{

public static Boolean triggervar= true;

}
This was selected as the best answer
udayarangareddy mekalaudayarangareddy mekala
Thanks ASHA