新規オブジェクトの作成
新しいオブジェクトを作成するには、次のステップに従います:
-
newView()
関数を使用して、問題のビジネス・オブジェクトのプログラム・アクセス用のビュー・オブジェクトを取得 -
ビュー・オブジェクトで
createRow()
関数をコールして、新しい行を作成 -
新しい行で必要なフィールド値を設定
-
ビュー・オブジェクトで
insertRow()
をコールして、行を挿入します。
新しいオブジェクトは、次に現在のトランザクションの一部として作業を保存したときに保存されます。 次の例は、各ステップが実際にどのように連携するかを示しています。
// 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.