You need to sign in to do that
Don't have an account?

Find a specific record Type
Hi
How can I recognize a specific record Type. Requirement is that when there is a record Type A then put a validation on a field. But how can I recognize a recordtype by its name such as A in this case. I was doing some in the below lines and obviously it does not work as 3rd statement is incorrect. Can anyone please point out something
List<Object> items
for(Object item : items)
if(item.RecordTypeId.getName().equals('A')){ //DOES NOT WORK
if(item.B == null){
do stuff
}
}
}
How can I recognize a specific record Type. Requirement is that when there is a record Type A then put a validation on a field. But how can I recognize a recordtype by its name such as A in this case. I was doing some in the below lines and obviously it does not work as 3rd statement is incorrect. Can anyone please point out something
List<Object> items
for(Object item : items)
if(item.RecordTypeId.getName().equals('A')){ //DOES NOT WORK
if(item.B == null){
do stuff
}
}
}
Please try below code . Let us know if it helps you.
Hi
Hope this code will help!
Map<ID,RecordType> rt_map = New Map<ID,RecordType>([Select ID, Name From RecordType Where sObjectType = 'case']);
for(case c : items){
if(rt_map.get(c.recordTypeID).name.containsIgnoreCase('YOUR VALUE')){
//Do your stuff
}
}