Sample Notification Scripts
This topic contains sample notification scripts you can use for different objects. These are for reference only. Your own business requirements may mean you use different scripts.
Account Sample Scripts
Here are some sample scripts for the Account object:
Use Case 1: Notifies the owner of an account that a new account has been assigned to her
Notification and Navigation Details
-
Notification information: New account: <account name>
-
Sent to: Owner of the account
-
Navigates user to: Account details page
Type
Before Insert in Database
Script
/def upID = adf.util.getUserPartyId();
if (isAttributeChanged('OwnerPartyId') && OwnerPartyId!=upID)
{ try { def map = new HashMap(); // Specifying the recipient def recipientPartyId
= OwnerPartyId // Specify default MessageText def messageText = "New
Account : '" + OrganizationName + "'." // Specify one or more channels
map.put("Channels",["ORA_SVC_BELL"]); map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId map.put("RecipientPartyId",
recipientPartyId); if (recipientPartyId) { // Call to send notification
adf.util.sendNotification(adf, map)
Use Case 2: Notifies the owner of an account that another user has been assigned as the account owner
Notification and Navigation Details
-
Notification information: Account assigned: <account name>
-
Sent to: Owner of the account
-
Navigates user to: Account details page
Type
Before Update in Database
Script
/if (isAttributeChanged('OwnerPartyId'))
{ try { def map = new HashMap(); // Specifying the recipient def recipientPartyId
= OwnerPartyId // Specify default MessageText def messageText = "Account
Assigned: '" + OrganizationName + "'." // Specify one or more channels
map.put("Channels",["ORA_SVC_BELL"]); map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId map.put("RecipientPartyId",
recipientPartyId); if (recipientPartyId) { // Call to send notification
adf.util.sendNotification(adf, map)
Activity Sample Script
Here is a sample script for the Activity object:
Use Case: Notifies the assignee of a task when a task is assigned to him
Notification and Navigation Details
-
Notification information: Task assigned: <task name>
-
Sent to: Assignee
-
Navigates user to: Task details page
Type
Before Update in Database
Script
/if (isAttributeChanged('OwnerId')
&& ActivityFunctionCode == 'TASK') { try { def map = new HashMap();
def messageText = "Task assigned: " def recipientPartyId = OwnerId
// Specify one or more channels map.put("Channels",["ORA_SVC_BELL"]);
// Specify default MessageText map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId map.put("RecipientPartyId",
recipientPartyId); if (recipientPartyId) { adf.util.sendNotification(adf,
map) } else { println("No Owner associated with this Task") } } catch
(e) { throw new oracle.jbo.ValidationException('Failure to trigger
Notification from Groovy Script: ' + e.getMessage()) } }
Contact Sample Scripts
Here are some sample scripts for the Contact object:
Use Case 1: Notifies the owner of a contact that a new contact has been assigned to her
Notification and Navigation Details
-
Notification information: New contact: <contact name>
-
Sent to: Owner of the contact
-
Navigates user to: Contact details page
Type
Before Insert in Database
Script
/def upID = adf.util.getUserPartyId();
if (isAttributeChanged('OwnerPartyId') && OwnerPartyId!=upID)
{ try { def map = new HashMap(); // Specifying the recipient def recipientPartyId
= OwnerPartyId // Specify default MessageText def messageText = "New
Contact: '" + PersonName + "'." // Specify one or more channels map.put("Channels",["ORA_SVC_BELL"]);
map.put("MessageText", messageText); // The following can be used
to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { // Call to send notification adf.util.sendNotification(adf,
map)
Use Case 2: Notifies the owner of a contact that another user has been assigned as the contact owner
Notification and Navigation Details
-
Notification information: Contact assigned: <contact name>
-
Sent to: Owner of the contact
-
Navigates user to: Contact details page
Type
Before Update in Database
Script
/ if (isAttributeChanged('OwnerPartyId'))
{ try { def map = new HashMap(); // Specifying the recipient def recipientPartyId
= OwnerPartyId // Specify default MessageText def messageText = "Contact
Assigned: '" + PersonName + "'." // Specify one or more channels map.put("Channels",["ORA_SVC_BELL"]);
map.put("MessageText", messageText); // The following can be used
to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { // Call to send notification adf.util.sendNotification(adf,
map)
Contest and Goal Sample Scripts
Here are some sample scripts for the Contest and Goal objects:
Use Case 1: Notifies participants of a contest that a contest has been created
Notification and Navigation Details
-
Notification information: Contest created: <contest name>
-
Sent to: Contest participants
-
Navigates user to: Contest details page
Type
Before Insert in Database
Script
/def map = new HashMap(); //
Specify one or more channels map.put("Channels",[ "ORA_SVC_BELL"]);
// Specify default MessageText def messageText = "Contest created:
" + ContestName; map.put("MessageText", messageText); // The following
can be used to pass a Long PartyId map.put("RecipientPartyId", OwnerId);
adf.util.sendNotification(adf, map)
Use Case 2: Notifies goal participants that a new goal has been created
Notification and Navigation Details
-
Notification information: Goal created: <goal name>
-
Sent to: Participants
-
Navigates user to: Goal details page
Type
Before Update in Database
Script
// Specify one or more channels
map.put("Channels",["ORA_SVC_BELL"]); // Specify default MessageText
map.put("MessageText", messageText); // The following can be used
to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { adf.util.sendNotification(adf, map) } else
{ println("No Owner associated with this Goal") } } catch (e) { throw
new oracle.jbo.ValidationException('Failure: ' + e.getMessage()) }
}
Lead Sample Scripts
Here are some sample scripts for the Lead object:
Use Case 1: Notifies lead owner that a new lead has been assigned to him
Notification and Navigation Details
-
Notification information: Lead assigned: <lead name>
-
Sent to: Owner
-
Navigates user to: Lead details page
Type
Before Update in Database
Script
/if (isAttributeChanged('OwnerId'))
{ try { def map = new HashMap(); def messageText = "Lead Assigned:
" + Name def recipientPartyId = OwnerId // Specify one or more channels
map.put("Channels",["ORA_SVC_BELL"]); // Specify default MessageText
map.put("MessageText", messageText); // The following can be used
to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { adf.util.sendNotification(adf, map) } else
{ println("No Owner associated with this Lead") } } catch (e) { throw
new oracle.jbo.ValidationException('Failure: ' + e.getMessage()) }
}
Use Case 2: Notifies the lead owner when a lead is assigned to her but the signed-in user has a userPartyId that's different from the lead owner of the lead
Notification and Navigation Details
-
Notification information: New lead: <lead name>
-
Sent to: Owner
-
Navigates user to: Lead details page
Type
Before Insert in Database
Script
/def upID = adf.util.getUserPartyId();
if (isAttributeChanged('OwnerId') && OwnerId!=upID) { try
{ def map = new HashMap(); def messageText = "New Lead: " + Name def
recipientPartyId = OwnerId// Specify one or more channels map.put("Channels",["ORA_SVC_BELL"]);
// Specify default MessageText map.put("MessageText", messageText);
// The following can be used to pass a Long PartyId map.put("RecipientPartyId",
recipientPartyId);if (recipientPartyId) { adf.util.sendNotification(adf,
map) } else { println("Notification is not sent as Owner of this Lead:
"+ Name + " is same as logged in user"); } } catch (e) { throw new
oracle.jbo.ValidationException('Failure: ' + e.getMessage()) } }
Opportunity Sample Scripts
Here are some sample scripts for the Opportunity object:
Use Case 1: Notifies the opportunity owner when an opportunity has been assigned to her
Notification and Navigation Details
-
Notification information: Opportunity assigned: <opportunity name>
-
Sent to: Owner
-
Navigates user to: Opportunity details page
Type
Before Update in Database
Script
/if (isAttributeChanged('OwnerResourcePartyId'))
{ try { def map = new HashMap(); def messageText = "Opportunity Assigned:
" + Name def recipientPartyId = OwnerResourcePartyId // Specify one
or more channels map.put("Channels",["ORA_SVC_BELL"]); // Specify
default MessageText map.put("MessageText", messageText); // The following
can be used to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { adf.util.sendNotification(adf, map) } else
{ println("No Owner associated with this Opportunity") } } catch (e)
{ throw new oracle.jbo.ValidationException('Failure: ' + e.getMessage())
} }
Use Case 2: Notifies the opportunity owner when an opportunity is assigned to them, but the signed-in user has a userPartyId that's different from him
Notification and Navigation Details
-
Notification information: New opportunity: <opportunity name>
-
Sent to: Owner
-
Navigates user to: Opportunity details page
Type
Before Insert in Database
Script
/def upID = adf.util.getUserPartyId();
if (isAttributeChanged('OwnerResourcePartyId') && OwnerResourcePartyId!=upID)
{ try { def map = new HashMap(); def messageText = "New Opportunity:
" + Name def recipientPartyId = OwnerResourcePartyId // Specify one
or more channels map.put("Channels",["ORA_SVC_BELL"]); // Specify
default MessageText map.put("MessageText", messageText); // The following
can be used to pass a Long PartyId map.put("RecipientPartyId", recipientPartyId);
if (recipientPartyId) { adf.util.sendNotification(adf, map) } else
{ println("Notification is not sent as Owner of this Opportunity:
"+ Name + " is same as logged in user"); } } catch (e) { throw new
oracle.jbo.ValidationException('Failure: ' + e.getMessage()) } }