• Regina Obe 9
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I ran all the Apex Unit Tests and 5 CMSForce classes are failing.  They all come from the trigger checkObjectAPIName with the error "The Object API name is not correct."  I believe it is not the code itself but some data in the system causing the problem.  However, I'm not sure how to research "this happens when the object's API name doesn't exist, or has been removed from the profile access settingsTypically when admin's don't setup the webform editor correctly"

Thanks

 

trigger checkObjectAPIName on Web_Form__c (before insert, before update) {

  //Map that holds all the object names and tokens in your org
  Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();

  for(Web_Form__c form:Trigger.New) {
        //just for other tests, provide a bypass to this one
        if(form.Object_Name__c.contains('testbypassx')) continue;
        //get a reference to the token related to the object referenced in the webform
        SObjectType sot = gd.get(form.Object_Name__c);
        //instantiate an object of this type
        try {
          SObject sobjectInstance = sot.newSObject();
        }
        //this happens when the object's API name doesn't exist, or has been removed from the profile access settings
        //Typically when admin's don't setup the webform editor correctly
        catch(System.NullPointerException ex) {
          form.addError('The Object API name is not correct.');          
        }

 

 

  • November 14, 2012
  • Like
  • 0