You need to sign in to do that
Don't have an account?
chaithaly gowda
how to compare record type id in test class
Hi
I have to compare the record type id/name using system.assertequals();
Task task = new Task();
task.Subject = 'Test Send New Task Email Notification';
task.Status = 'Not Started';
task.ActivityDate = Date.Today();
task.Priority = 'Normal';
task.RecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId();
insert(task);
}
system.assertEquals(Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId(),task.recordtypeid);
Test.stopTest();
I am getting below error
Comparison arguments must be compatible types: Id, Schema.SObjectField
I have to compare the record type id/name using system.assertequals();
Task task = new Task();
task.Subject = 'Test Send New Task Email Notification';
task.Status = 'Not Started';
task.ActivityDate = Date.Today();
task.Priority = 'Normal';
task.RecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId();
insert(task);
}
system.assertEquals(Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId(),task.recordtypeid);
Test.stopTest();
I am getting below error
Comparison arguments must be compatible types: Id, Schema.SObjectField
Let me know if it helps