• ss kumar
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
trigger CaseDemoRecordType on Case (After insert , After update)
{
    if((trigger.isAfter) && (trigger.isinsert || trigger.isupdate))
    {
    List<RecordType> recordTyp = [Select id , Name , Sobjecttype from RecordType];
    List<Case> LstCs = [select id , CaseNumber , RecordTypeId from case ]; 
    
    For(Case cs : Trigger.new)
    {
        For(RecordType RecTyp : recordTyp )
        {
            
          If(cs.RecordTypeID == RecTyp.id)
        {
            if(RecTyp.Name == 'School zone')
            {
                cs.Description = 'This is SCHOOL ZONE';
                system.debug('This is SCHOOL zONE^^^^^'+RecTyp.Name);
            }
            else
                cs.Description = 'This is COLLEGE ZONE';
                system.debug('This is COLLEGE zONE......'+RecTyp.Name);
            
            system.debug('The REcord Type Ids..............'+cs.RecordTypeId);

        }
        }
                            update cs;

    }

    }
}
my requirment is i've one object in this object i've two record types .when ever i create or update the record i want to display the specific record type name in decription field.

I have a requirement I want to Count all total case records and count of Which case status was New