Creating a New Object

To create a new object, follow these steps:

  1. Use the newView() function to obtain the view object for programmatic access for the business object in question

  2. Call the createRow() function on the view object to create a new row

  3. Set the desired field values in the new row

  4. Call insertRow() on the view object to insert the row.

The new object will be saved the next time you save your work as part of the current transaction. The example below shows how the steps fit together in practice.

// Access the view object for the custom TroubleTicket object
def vo = newView('TroubleTicket')
// Create the new row
def newTicket = vo.createRow()
// Set the problem summary
newTicket.ProblemSummary = 'Cannot insert floppy disk'
// Assign the ticket a priority
newTicket.Priority = 2
// Insert the new row into the view object
vo.insertRow(newTicket)
// The new data will be saved to the database as part of the current
// transaction when it is committed.