
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 10:33 PM
I would like to be able to generate a notification when someone returns an asset.
Wondering how I can automate it to the correct person after their name has been removed from the field already.
EG:
Joe Bloggs is the person in the assigned_to field for asset xyzabc
Joe returns the asset and is removed from the field (it remains blank) and the asset is updated, at this point I'd like a notification sent to Joe Bloggs advising that he has returned the asset - sort of like a receipt in case later someone asks him where it is, he can prove he returned it.
Ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 11:37 PM
please use previous object in BR script
(function executeRule(current, previous /*null when async*/) {
gs.eventQueue('asset.assigned.removed', current, previous.assigned_to.email.toString());
})(current, previous);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 10:43 PM
Hi,
you can use after update BR and trigger the notification via eventQueue
in that event queue function parameter you can send details of the old user
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 10:54 PM
Thank you, so do I just reference the same field and it will automatically pick up the previous entry?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 11:00 PM
Hi,
nope not like that
Steps
1) You can use Before update BR then
2) create event, notification on asset table
a) Ensure Event parm1 contains recipient is checked on Notification
BR script will be like this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.eventQueue('event_name', current, current.assigned_to.email.toString());
})(current, previous);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2022 11:32 PM
Ok thanks @Ankur Bawiskar , So I have a business rule:
Name: Asset Assigned Removed
Table: Asset {alm_asset}
Before / Update
Conditions:
assigned_to changes
assigned_to is empty
Advanced:
(function executeRule(current, previous /*null when async*/) {
gs.eventQueue('asset.assigned.removed', current, current.assigned_to.email.toString());
})(current, previous);
Then an event:
name: asset.assigned.removed
Table: Asset {alm_asset}
Fired by: Business Rule
Then a notification:
Name: Asset Returned
Table: Asset {alm_asset}
Send when - event is fired
Event Name - asset.assigned.removed
Who will receive:
event parm 1 contains recipient (checked) and sent to event creator (checked)
What will it contain:
Subject - example
Body - example
I've then tested by removing the assigned_to person and no notification is sent, however I can see that the even is firing.
Ideas?