Created
May 23, 2013 18:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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