Conditional coalesce script creates record with sys_id of "-1"

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2018 08:57 AM
I have to do a conditional coalesce on an inbound record, so I'm using a script that tries to find my target record, and if it can't, it returns -1, as explained at https://docs.servicenow.com/bundle/kingston-platform-administration/page/administer/import-sets/conc...
For example, my field map script, which is set to coalesce, is:
answer = (function transformEntry(source) {
var gr = new GlideRecord('incident');
var qc = gr.addQuery('correlation_id', source.u_sys_id);
qc.addOrCondition('sys_id', source.u_correlation_id);
gr.query();
if (gr.next()) {
return gr.sys_id;
}
else {
return -1;
}
})(source);
This works fine in most cases, but I have seen examples where this just ends up creating an incident with a sys_id of "-1". Any idea what could cause that?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 07:18 AM
I'm also facing the same issue, Could you please provide the solution