Transform map script inserts a new record instead of updating the queried record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 08:05 AM
Please find the below code- where we compare the manufacturer attribute from the data source table to the cmdb_ci table- if it finds a matching manufacturer record, the serial no attribute( cmdb_ci table) of the same record should get populated with the serial no from the data source table.
Issue- Instead of populating the serial no for the matching record, it creates a new record.
var gr= new GlideRecord("cmdb_ci");
gr.addQuery('manufacturer',source.u_manufacturer);
gr.query();
while ((gr.next()));
{
if (target.u_serial_number== source.u_serial_number);
gr.setValue(target.u_serial_number, source.u_serial_number);
gr.update();
}
- Labels:
-
Discovery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 08:28 AM
Hi Arathi B Raj,
If your target table is "cmdb_ci" only then no need to use gr. update. Simple use the below script and should work. You could also use "Source script" as a field map as well. Thanks.
var gr= new GlideRecord("cmdb_ci");
gr.addQuery('manufacturer',source.u_manufacturer);
gr.query();
if((gr.next()));
{
if (target.u_serial_number== source.u_serial_number);
target.u_serial_number=source.u_serial_number;
}
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 08:41 AM
Hi Nayan
Thanks for the help!
I tried the above script as well but still it is creating new records instead of updating.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 08:16 PM
Hi Arathi,
What is your target table in the transform map?
And also make sure that in the filed mapping you have made "u_serial_number" as coalesce true.
Regards,
Nayan