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
Eesha.SinghEesha.Singh 

I have a scenario when a task is created/ipdated the owner.Profile should determine the task record type. I am new to triggers, any help would be appreciated.

I tried process builder and workflows both did not work.
Record type is a lookup field, so is the owner.
VineetKumarVineetKumar
You can take helpe from the below sample code
trigger IntakeFormTrigger on Apttus__APTS_Agreement__c (after insert, before update) {
 
    // Get a list of record types.
    Map<ID,RecordType> typeMap = New Map<ID,RecordType>([Select ID, DeveloperName From RecordType Where sObjectType = 'Apttus__APTS_Agreement__c']);
  
  // Get the IntakeForm RecordTypeId
    id IntakeFormRT = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Intake Form').getRecordTypeId(); 
	
    for (Apttus__APTS_Agreement__c agmt : trigger.new)
    {
        // If the Record Type = Intake Form
        if (agmt.RecordTypeId == IntakeFormRT)
        {
            // And the Agreement Category on the record =TEST
                if (agmt.Apttus__Agreement_Category__c == 'TEST')
                {
                    // Then automatically change the Record Type to TEST Agreements.
                    agmt.RecordType = typeMap.get('TEST Agreements');
                }
        }          
    }
}