- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 02:12 AM - edited 12-20-2023 02:12 AM
Hi everyone,
I am trying to create an email notification using business rule and event registry where an email is generated with details of an asset. However, my following structure uses .getDisplayValue for assigned_to field and that returns an ID instead of the user name.
Could anyone advise me on the following steps to achieve the expected result?
My workflow is based on the following:
Event Registry
Event name asset.assign.notification
Table alm_hardware
Fired by Business Rule: Asset Assign Changes
Business rule
(function executeRule(current, previous /*null when async*/) {
//If the asset assigned to changes, queue the event
if(current.assigned_to.changes()){
//Get previous value
var value = previous.assigned_to.getDisplayValue();
//Get current value
var newValue = current.assigned_to.getDisplayValue();
gs.eventQueue("asset.assign.notification", current, value, newValue);
}
})(current, previous);
Notification
Table alm_hardware
Type EMAIL
Active true
When to send:
Send when Event is fired
Event name asset.assign.notification
Who will receive:
Users System Administrator
What it will contain:
Subject The asset assigned to has changed
Message HTML
The following asset: ${asset_tag} assigned to has changed from:${event.parm1} to: ${event.parm2} and that has been changed by: ${sys_updated_by}.
Regards,
IT
Preview Notification
The following asset: P1000479 assigned to has changed from:6816f79cc0a8016401c5a33be04be441 to: and that has been changed by: admin.
Regards,
IT
Thank you in advance for you time.
Regards,
Gio
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 02:31 AM
Use the below code it must help , bcoz the emaill body accepts HTML/TEXT. Replace to the below 2 lines in your code.
var value = previous.assigned_to.name.toString();
var newValue = current.assigned_to.name.toString();
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 02:27 AM - edited 12-20-2023 02:28 AM
Hello,
Looking at you output seems that the user table does not have a display value so it is returning the sysid.
Please use the below code and change your BR to before update if not done already.
(function executeRule(current, previous /*null when async*/) {
//If the asset assigned to changes, queue the event
if(current.assigned_to.changes()){
//Get previous value
var value = previous.assigned_to.name;
//Get current value
var newValue = current.assigned_to.name;
gs.eventQueue("asset.assign.notification", current, value, newValue);
}
})(current, previous);
Please mark my answer as correct based on impact,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 02:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 02:31 AM
Use the below code it must help , bcoz the emaill body accepts HTML/TEXT. Replace to the below 2 lines in your code.
var value = previous.assigned_to.name.toString();
var newValue = current.assigned_to.name.toString();
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 06:00 AM
Hi @Sohail Khilji,
That has actually worked and such a simple fix.
Thank you so much for the help.
Regards,
Gio