簡易ビュー基準の使用
ビュー基準を使用してカスタム・オブジェクトまたは標準オブジェクトを検索するには、次のステップを実行します:
-
newView()
関数を使用したビュー・オブジェクトの作成 -
適切なフィルタ式を使用して、
appendViewCriteria()
関数でビュー基準を追加 -
executeQuery()
をコールして問合せを実行 -
結果の処理
次の例では、TroubleTicket
カスタム・オブジェクトを問い合せて、IDが100000000089003
で、ステータスがWorking
の特定のスタッフに割り当てられたトラブル・チケットを検索します。
/*
* Query all 'Working'-status trouble tickets assigned to a staff member with id 100000000089003
*/
// 1. Use the newView() function to get a view object
def vo = newView('TroubleTicket_c')
// 2. Append a view criteria using a filter expression
vo.appendViewCriteria("AssignedTo_Id_c = 100000000089003 and Status_c = 'Working'")
// 3. Execute the query
vo.executeQuery()
// 4. Process the results
if (vo.hasNext()) {
def row = vo.next()
// Do something here with the current result row
}