How to notify affected ci owners with their own information in change request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2016 08:19 AM
Hi!
What I am trying to do is to send an email notification to the ci owners when change request is in assess state.
I did this Business Rule.
Condition: current.state.changesTo(-4) // -4 is Assess State
Script:
var owners = '';
var ci = new GlideRecord('task_ci');
ci.addQuery('task',current.sys_id);
ci.query();
while(ci.next())
{
owners += ',' + ci.ci_item.owned_by;
}
gs.eventQueue("change.ciowner", current, owners, gs.getUserName()); // Event name change.ciowner
Notification.
What will contain:
========================================================================
Dear Customer: ${user.company_name} // this company name have to be the affected ci company of the owner.
According to our records the affected CI will be: ${ci_item} // this have to be affected ci
====================================================================
The notification is general and all the affected ci owners recive the same notification.
The problem here is that we want to send these notifications very specific per customer, that just show their own company information, like the owner company name [user.company_name] and the name of their affected ci.
My question is... Is there any way to send particular or specific notifications per affected ci owners?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 10:39 AM
Thank you.
If the idea is to have multiple notifications (one for each company), then I suggest you base the event name on the company name. Something like
change.notice.COMPANY_NAME
You MUST have each of the events in the event registry for this to work!
Event Registry - ServiceNow Wiki
In your business rule (or wherever you decide to trigger the notification), you create the event name and pass it. Something like:
var coName = ci.ci_item.owned_by.company.getDisplayName();
var eventName = 'change.notice.' + coName.replace(/\s+/g, '_');
gs.eventQueue(eventName, current, '', ''); // trigger the event to send the notification
Company names like "Acme Electronics" require an event name like "change.notice.Acme_Electronics"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2016 08:31 AM
So, that means that If I have 500 companies, I should have to create a Business Rule, an Event and a Notification per Company?
If the answer is Yes, Is there another way to Notify the Affected CI owners like I pretend?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2016 05:20 AM
Another option is to have varied content to each company would be to create a single notification per event (triggered by an event) and pass the company as an event parameter, for example:
gs.eventQueue('event.name', current, current.u_company, gs.getUserID());
Then use an email script in your notification to produce varied content based on the company value.
Scripting for Email Notifications - ServiceNow Wiki
Email Notifications - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2018 02:31 PM
Your business rule works well! Thank you for sharing it.