顧客がメッセージに返信したときに通知を受けるにはどうすればよいですか。
顧客がメッセージに返信したときに、「通知プリファレンス」ページで指定した受信者に通知が送信されるようトリガーするサンプル・コードを次に示します。
このサンプル・コードは、「アプリケーション・コンポーザ」>「オブジェクト」>「標準オブジェクト」>「サービス・リクエスト」>「メッセージ」>「サーバー・スクリプト」でコピーして貼り付けることができます。
/* DISCLAIMER: This trigger is provided only as a reference.
* TRIGGER TYPE: Before Insert to Database
* OBJECT: Message (child of Service Request)
* Use Case: Send a notification to the assignee when a customer entry is created.
* Note: You can override the Notification Text and Recipients using the Notification Preferences page.
*/
if (MessageTypeCd == 'ORA_SVC_CUSTOMER_ENTRY') {
try {
// Note: The notation ServiceRequest?.SrNumber is used because ServiceRequest is the parent
// object of Messages. To access the other possible field names, expand the trigger box, click on fx,
// click on Fields, and select the drop-down list from Message. Click on Service Request to see the
// available fields. You must click Insert to correctly insert the appropriate field into your script.
def messageText = "A customer entry was received for " + ServiceRequest?.SrNumber
def recipientPartyId = ServiceRequest?.AssigneeResourceId
if (recipientPartyId) {
// Call to send notification
adf.util.sendNotification(adf, messageText, recipientPartyId)
//Log a confirmation that the notification has been sent. Logs can be viewed in 'Runtime Messages'.
//println("Notification sent to " + recipientPartyId + " because a customer entry was received.")
} else {
println("No Assignee associated with this SR")
}
} catch (e) {
// Log the failure in groovy logging. Logs can be viewed in 'Runtime Messages'.
println("Failure to trigger notification from Groovy Script " + e.getMessage());
// Throwing validation exception will show the message on the UI. This is not recommended for published sandboxes.
// The following code is one of many to illustrate identifying an error in trigger from UI.
// Replace <triggerName> with the trigger name you specified when creating this trigger.
// throw new oracle.jbo.ValidationException('Failure to trigger <triggerName> Notification from Groovy Script: ' + e.getMessage())
}
}