MObject.apex

  • Docs
  • Tutorials
Docs Menu
  • MObject
  • MObject.Funcs
    • Funcs
  • MObject Instance
    • Creation Methods
    • Methods

Methods Guide

methods of MObjects

toMap

Convert the MObject to a map

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
Map data = mo.toMap(true);
NameDescription
toMap(Boolean)Convert to map, whether to trim namespace
toMap()Convert to map, keeping namespace

get

Get the value from MObjects

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
String name = (String)mo.get('LastModifiedBy.Name', 'Unknown');
NameDescription
get(String, Object)Get the value of the path, returning default value if null
get(String)Get the value of the path
get(List, Object)Get the value of the path, returning default value if null
get(List)Get the value of the path

put

Update the value of the MObjects

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
mo.put('LastModifiedBy.Name', 'Wilson');
NameDescription
put(String, Object)Update the value of the path
put(List, Object)Update the value of the path

markAsDeleted

Mark the MObjects as deleted

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
mo.markDeleted(true);
NameDescription
markAsDeleted()Mark the MObject as deleted
markAsDeleted(Boolean)Mark the MObject as deleted, cascadingly

isDirty

Check if the MObject is dirty

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
Boolean dirty = mo.isDirty();

isDeleted

Check if the MObject is marked as deleted

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
Boolean deleted = mo.isDeleted();

persist

Persist the MObject

MObject mo = MObject.create(new Pricebook2(Name='pricebook'));
mo.put('Name', 'new name');
mo.persist();

List mos = MObject.createList(new List());
for(MObject mo : mos) {
    mo.put('Name', 'new name');
}
MObject.persist(mos);

Contribute on Github! Edit this section.