• suman
  • NEWBIE
  • 0 Points
  • Member since 2010

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

You can use Dynamic DML to insert untyped SObjects one-at-a-time, but not as an array:

SObjectType token = Schema.getGlobalDescribe().get('contact');
SObject[] objs = new SObject[0];
for (integer i = 0; i<2; i++) {
SObject tmp = token.newSObject();
tmp.put('LastName', 'test' + i);
objs.add(tmp);
}

boolean showBug = true;

if (showBug) { // fails with "DML not allowed on abstract class SObject"
insert objs;
}
else { // works
for (SObject i : objs) insert i;
}

 

 

  • April 15, 2010
  • Like
  • 0