• 1Installation
  • 2Preliminary Knowledge
  • 3Create MObjects
  • 4Manipuate MObjects
  • 5Delete MObjects
  • 6Persistence
  • 7Namespace Free
  • 8Functional Support

MObject.apex

  • Docs
  • Tutorials
Getting started with MObject.apex

Delete MObjects

You cannot directly delete MObjects. You can only mark them as deleted, so that deletion operation will be carried out on them during persistence.

Pricebook2 pb = [ ... ];
MObject mo = MObject.create(pb);
mo.markDeleted();

You can mark an MObject as cascading delete, and this will in turn mark all the children MObjects to be deleted.

Pricebook2 pb = [ ... ];
MObject mo = MObject.create(pb);
// All referencing opportunities will be marked as deleted
mo.markDeleted(true);
Done