New answers tagged

2

The problem is an invalid (or null) return on the Type class using forName. You need to validate the return of forName before looking to cast into an SObjectType String myString = 'InvalidClass'; Type classType = Type.forName(myString); SObjectType sObjType; if (classType != null) { sObjType = ((SObject) classType.newInstance()).getSObjectType(); }


Top 50 recent answers are included