サービス・リクエスト・リソースの追加
これは、そのメンバーがSRに追加されたときに新しいリソース・メンバーに通知をトリガーするサンプル・コードです。
このサンプル・コードは、「アプリケーション・コンポーザ」>「オブジェクト」>「標準オブジェクト」>「サービス・リクエスト」>「サービス・リクエスト・リソース」>「サーバー・スクリプト」でコピーおよびペーストできます。
/* DISCLAIMER: This trigger is provided only as a reference.
* TRIGGER TYPE: Before Insert to Database
* OBJECT: Service Request Resource (child of Service Request)
* Use Case: Send a notification to a new resource member when that member is added to an SR.
*/
try {
def map = new HashMap();
// Specify default MessageText
def messageText = "You are now a team member"
// Specifying the recipient
def recipientPartyId = PartyPartyId
//Resolving Parent child object relation. Use respective parent object apinames. Eg: ServiceRequestVO,HRHelpDeskRequestVO
def objectCode='ServiceRequestVO'
Long objectId = SrId
// Specify one or more channels
map.put("Channels",["ORA_SVC_BELL","ORA_SVC_EMAIL"]);
map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId
map.put("RecipientPartyId", recipientPartyId);
map.put("ObjectCode", objectCode);
map.put("ObjectId",objectId)
if ( recipientPartyId != null ) {
// Call to send notification
adf.util.sendNotification(adf, map);
}
else {
println("No recipient. Notification will not be sent.");
}
}
catch (e) {
// Log the failure in groovy lo'RuntimeMessages'.
println("Failure to trigger notification from Groovy Script " +
e.getMessage());
}