Skip to content

Instantly share code, notes, and snippets.

@rupton
Created May 23, 2013 18:03
Show Gist options
  • Save rupton/5638088 to your computer and use it in GitHub Desktop.
Save rupton/5638088 to your computer and use it in GitHub Desktop.
Apex Code to compare SObjects against other types in support of force.com blog entry
public class ObjectHelper{
public static boolean compareTypes(SObject compare, String checkType){
try{
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(checkType);
if(targetType == null){
return false;
}else if( compare.getSObjectType() == targetType){
return true;
}
}catch(Exception e){
//handle exception
return false;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment