- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 03:38 PM
Hello,
I am trying to figure out how to remove a change calendar meeting when a change state is modified to canceled. I am running Helsinki and have confirmed that the out of box Notify Change Calendar Remove notification is working when assigned to or date is changed per the business rule (Change Events).
I have tried to add the condition to the Notify Change Calendar Remove notification but didn't send notification when change was canceled. I also tried to add the below code to the change events business rule and still can't get it to send remove notification based on change being set to a state of canceled.
Any ideas on how to accomplish this would be greatly appreciated.
// Remove old calendar from current assigned to, due to state change canceled
if (current.state.changes() && current.state== 4) {
gs.eventQueue("change.calendar.notify.remove", current, current.state, previous.state);
}
}
Thanks,
Nolan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 12:19 PM
I just tested in my personal dev instance, and cancelled a change. Here is the full code working:
if (current.operation() == 'insert') {
gs.eventQueue("change.inserted", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'update') {
gs.eventQueue("change.updated", current, gs.getUserID(), gs.getUserName());
}
if (!current.assigned_to.nil() && current.assigned_to.changes()) {
gs.eventQueue("change.assigned", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());
}
if (current.priority.changes() && current.priority == 1) {
gs.eventQueue("change.priority.1", current, current.priority, previous.priority);
}
if (current.risk.changes() && current.risk== 1) {
gs.eventQueue("change.risk.1", current, current.risk, previous.risk);
}
if (current.start_date.changes() || current.end_date.changes() || current.assigned_to.changes()) {
if (!current.start_date.nil() && !current.end_date.nil() && !current.assigned_to.nil()) {
gs.eventQueue("change.calendar.notify", current, current.assigned_to, previous.assigned_to);
}
// Remove from previous assigned to, due to assigned_to changing
if (!previous.assigned_to.nil()) {
if (!current.assigned_to.nil() && current.assigned_to.changes() &&
(!previous.start_date.nil() && !previous.end_date.nil())) {
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, previous.assigned_to);
}
}
// Remove old calendar from current assigned to, due to date changing
else if (!current.assigned_to.nil()) {
if ((current.start_date.changes() && !previous.start_date.nil()) ||
(current.end_date.changes() && !previous.end_date.nil())) {
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, current.assigned_to);
}
}
}
if(current.state.changesTo(4)){
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to);
}
You can see line 50-52 is what I added to the OOB script.
Event Fired:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 12:19 PM
I just tested in my personal dev instance, and cancelled a change. Here is the full code working:
if (current.operation() == 'insert') {
gs.eventQueue("change.inserted", current, gs.getUserID(), gs.getUserName());
}
if (current.operation() == 'update') {
gs.eventQueue("change.updated", current, gs.getUserID(), gs.getUserName());
}
if (!current.assigned_to.nil() && current.assigned_to.changes()) {
gs.eventQueue("change.assigned", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());
}
if (current.priority.changes() && current.priority == 1) {
gs.eventQueue("change.priority.1", current, current.priority, previous.priority);
}
if (current.risk.changes() && current.risk== 1) {
gs.eventQueue("change.risk.1", current, current.risk, previous.risk);
}
if (current.start_date.changes() || current.end_date.changes() || current.assigned_to.changes()) {
if (!current.start_date.nil() && !current.end_date.nil() && !current.assigned_to.nil()) {
gs.eventQueue("change.calendar.notify", current, current.assigned_to, previous.assigned_to);
}
// Remove from previous assigned to, due to assigned_to changing
if (!previous.assigned_to.nil()) {
if (!current.assigned_to.nil() && current.assigned_to.changes() &&
(!previous.start_date.nil() && !previous.end_date.nil())) {
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, previous.assigned_to);
}
}
// Remove old calendar from current assigned to, due to date changing
else if (!current.assigned_to.nil()) {
if ((current.start_date.changes() && !previous.start_date.nil()) ||
(current.end_date.changes() && !previous.end_date.nil())) {
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to, current.assigned_to);
}
}
}
if(current.state.changesTo(4)){
gs.eventQueue("change.calendar.notify.remove", current, current.assigned_to);
}
You can see line 50-52 is what I added to the OOB script.
Event Fired:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 01:38 PM
Thank you!
I was able to get the change.calendar.notify.remove event to fire when canceled but not able to get the notification to work.
I have tried making these modifications to the Notify Change Calendar Remove notification but none of them worked.
- Added condition of state is Canceled
- Removed true from Advanced Condition
- Made sure Send to event creator is selected.
Thanks for all your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 02:18 PM
You don't need the conditions on the notification itself, as the logic is in your business rule. You'll need to setup your notifications like my screenshots below:
Make sure the "when to send" is the event name you're calling in your business rule. The notification will be sent when the event is fired.
Here is how my notification is setup:
Notice, I'm using a email template in my notification:
Make sure your email template has the content below in the "Message" section, NOT the "Message HTML".
This goes in your "Message" field, this is the format to send for outlook email clients:
BEGIN:VCALENDAR
PRODID:-//Service-now.com//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:CANCEL
BEGIN:VEVENT
ORGANIZER:MAILTO:${from}
LOCATION:${location}
TRANSP:OPAQUE
DTSTART:${dtstart}
DTEND:${dtend}
SEQUENCE:${sys_mod_count}
UID:${number}
DTSTAMP:${dtstamp}
DESCRIPTION:${description}
SUMMARY:${summary}
PRIORITY:3
X-MICROSOFT-CDO-IMPORTANCE:${priority}
STATUS:CANCELLED
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2017 02:42 PM
Jeffrey,
Thank you for all your help I have it working at this time using your code and adding the "assigned to" to the who will receive tab on the notification. I guess I thought it wasn't needed since it wasn't for the other removal conditions in the BR but makes sense it would be after looking at the code closer.
Once again thank you very much appreciate all your help and time!
Nolan Jensen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
You ALL missed a very important check: Is the Change Calendar created by a simple Report?
If yes, just add a condition like "State is not Cancelled."
NO scripting, NO modifications of events or notifications. One change to a report.