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
sourabh kalvasourabh kalva 

Write trigger that handles the following. Whenever a case is created with origin as ‘Phone’, set status as ‘New’ and Priority as ‘High’ and assign it to the user ‘XXXXX’. Retrieve the details of user using the user name ‘XXXXX’.

 Write trigger that handles the following. Whenever a case is created with origin as ‘Phone’, set status as ‘New’ and Priority as ‘High’ and assign it to the user ‘XXXXX’. Retrieve the details of user using the user name ‘XXXXX’.
sfdc98sfdc98
Hi, try below trigger

trigger caseex on Case (before insert,after insert) {
   
    user u=[select id,name from user where alias='xxxx'];
    for(Case c:trigger.new){
        if(trigger.isBefore){
        if(c.Origin=='phone'){
            
            c.Status='New';
            c.Priority='High';
            c.OwnerId=u.id;
            
        }
        }
       
    }
    
    
}