Transform Map: How to display a custom error when a coalesce field is empty?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi everyone,
I’m working on a Transform Map where one of the fields is set as coalesce.
I would like to show a custom error message in import_log when this coalesce field is empty in the source data.
I tried adding this check in the onBefore script:
if (!source.u_code || source.u_code.toString().trim() === '') {
ignore = true;
source.sys_import_state_comment = "Obligatory field missing: Code";
}
However, this script is never executed when the coalesce field is empty.
Instead, I always get ServiceNow’s standard error:
"Unable to resolve the target record, coalesce field values are not present..." in sys_import_set_row
It seems the Transform Map engine throws this error before the onBefore script runs, so my message never appears.
How can I handle this situation and display my own validation message ?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
try to use before insert BR on your staging table
something like this
(function executeRule(current, previous /*null when async*/ ) {
if (!current.u_code || current.u_code.toString().trim() === '') {
current.state = 'rejected';
current.comments = 'Obligatory field missing: Code';
}
})(current, previous);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
didn't work , I still get the servicenow standard message appearing
