Skip to content

When apex trigger actions have generic list<SObject> as parameters, calling 'getSObjectType' on entry-criteria filtered triggerNew returns null #189

@Th3Nathan

Description

@Th3Nathan

Expected Behavior

If the parameters for an apex action are generic 'List', calling 'getSObjectType' on those parameters should return the records' SObject type.

Actual Behavior

If any entry criteria is set, calling getSObjectType returns null.

Steps to Reproduce the Problem

  1. Create an apex trigger action where the parameters are generic 'List' and entry criteria is blank.
  2. calling 'getSObjectType' on triggerNew returns the SObjectType as expected
  3. Add any entry criteria to the action
  4. calling getSObjectType now returns null

Specifications

  • Version: 0.3.3
  • Platform: Developer Edition

Simple Trigger Action Class to Replicate

public with sharing class DynamicSObjectTriggerAction implements TriggerAction.BeforeUpdate {
  public void beforeUpdate(List<SObject> triggerNew, List<SObject> triggerOld) {
      Schema.SObjectType sobjectType = triggerNew.getSObjectType();
      
      // 'sobjectType' will be 'null' if any filter criteria is specified
      System.debug('SObjectType from triggerNew: ' + sobjectType);
  }
}

The Trigger Record Subclass to Replicate

global class AccountTriggerRecord extends TriggerRecord {
  global Account record {
    get {
      return (Account) this.newSObject;
    }
  }
  global Account recordPrior {
    get {
      return (Account) this.oldSObject;
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions