Conditional coalesce script for sys_id creates record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 02:25 AM
I have a scenario on multiple coalesce conditions. So I created coalesce on the sys_id field(script)
var gr = new GlideRecord("table");
gr.addQuery("field1", source.fieldA);
gr.query();
if (gr.next()) {
return gr.sys_id; // I tried with - answer = gr.sys_id;
} else {
var gr1 = new GlideRecord("table");
gr1.addQuery("field1", source.fieldB);
gr1.query();
if (gr1.next()) {
return gr1.sys_id; // I tried with - answer = gr1.sys_id;
} else{
return null; //I tried with : return -1 (and) return GlideGuid.generate(null); (and) answer = -1
}
}
// Its not working
If It does not match, should not create a new record. for that, I created onBefore with
if (action == 'insert') {
ignore = true;
}
Still creating new records.
Thanks in advance
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 05:59 AM
@SANJEEV4 so in the above code you can see i wrote a else loop which ignores the insertion
did you try then above method and got any luck of it ?