Checking for two coalesce not working hence writing script to check existing combination of twofiels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2024 09:27 AM - edited 06-29-2024 09:28 AM
Hi All,
Here I am checking for entity and ram field
if "xx" entity with "yy" ram exits in the table it should update record.
if "xx" with "zz" it should insert,
if "ss" with "yy" still create new record.
Both fields are reference fields, already added name in the both source fields as reference field.
already able to insert record but I want to update is same combination exits.
list view
above is the form view
successfully able to insert records please any one can help,
code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2024 10:15 AM
Hi,
Remove the existing coalesce and create a new script based one with the Target as sys_id. You can use the similar kind of code with the small change like this.
answer = (function transformEntry(source) {
var upd = new GlideRecord("sn_risk_advanced_risk_assessment_scope");
upd.addEncodedQuery('entity.name=' + source.u_entity + '^risk_assessment_methodology.nameSTARTSWITH' + source.u_ram); //Check whether record exits with same combination of entity and RAM
upd.query();
if (upd.next()) {
return upd.sys_id.toString()
} else {
return -1;
}
})(source);
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2024 10:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2024 06:05 PM - edited 06-29-2024 06:06 PM
Its a field map, not onbefore. Can you try like this. Make all other coalesce false and mark this one as true.
Thanks,
Narsing