Creating, Updating, and Deleting MBOs

Perform create, update, and delete operations on MBO instances.

You can call the create, update, and delete methods for MBO instances.

  1. Suppose you have an MBO named Customer. To create an instance within the database, invoke its create method, which causes the object to enter a pending state. Then call the MBO instance's submitPending method. Finally, synchronize with the generated database:
    Customer newcustomer = new Customer();
    //Set the required fields for the customer
    // …
    
    newcustomer.create();
    newcustomer.submitPending();
    SUP101DB.synchronize();
  2. To update an existing MBO instance, retrieve the object instance through a query, update its attributes, and invoke its update method, which causes the object to enter a pending state. Then call the MBO instance's submitPending method. Finally, synchronize with the generated database:
    Customer customer = Customer.findByPrimary(myCustomerId) //find by primary key
    customer.setCity("Dublin"); //update any field to a new value
    customer.update();
    customer.submitPending();
    SUP101DB.synchronize(); 
    
  3. To delete an existing MBO instance, retrieve the object instance through a query and invoke its delete method, which causes the object to enter a pending state. Then call the MBO instance's submitPending method. Finally, synchronize with the generated database:
    Customer customer = Customer.FindByPrimary(myCustomerId) //find by primary key
    customer.delete();
    customer.submitPending();
    SUP101DB.synchronize();
Related reference
Operations APIs