- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm having a problem where I try to get the value of the instance variable from a business rule on Insert of the table sys_email when an email is recieved.
I found that the value isn't defined after some updates, so I changed the business rule, but the sys_email is updated 4 times.
I'd like to know why ServiceNow does so many updates on the sys_email registry.
(function executeRule(current, previous /*null when async*/) {
if(current.instance) gs.log("id ritm: "+current.instance.toString());
else gs.log("INSTANCE NOT ASSIGNED");
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @AdriàM ,
sys_email records go through multiple system updates as inbound processing assigns values like instance. That’s why the field isn’t available on insert. Instead of an Insert BR, use an After Update BR with current.instance.changesToNotEmpty() or handle it in an Inbound Email Action to ensure your logic only runs once the field is set.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @AdriàM ,
have you tried current.getDisplayValue('instance') ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
what's your business requirement here?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @AdriàM ,
sys_email records go through multiple system updates as inbound processing assigns values like instance. That’s why the field isn’t available on insert. Instead of an Insert BR, use an After Update BR with current.instance.changesToNotEmpty() or handle it in an Inbound Email Action to ensure your logic only runs once the field is set.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Instead of onInsert, use an after update Business Rule with a condition on instance (so it triggers when ServiceNow assigns the email to a record)