- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 07:22 PM
Hello Community,
Is there any possibility without field map to update traget table records with import sets.If so can anyone help me with sample script and it will not create new records it should check source sys I'd with traget sys I'd if identity it should update the target records.
Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 08:01 PM
Hello,
You can use below script in transform map script to update target record:
var gr = new GlideRecord(target.getTableName());
gr.addQuery("sys_id", source.getValue("FIELD_NAME_HOLDING_SYS_ID_IN_SOURCE_TABLE"));
gr.query();
if(gr.next()){
//update fields here as per your requirement
gr.FIELD_NAME = source.FIELD_NAME;
gr.update();
}else{
ignore = true;
}
But I am wondering why you do not want to user field map and go for script. unless you need to manipulate/format data and then copy to target field, it is recommended to use field map as it is easiest way to configure transform map.
Thank you,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 01:43 AM
Is u_element_id field has sys_id or number value?
try below script to cover both scenarios:
var gr = new GlideRecord('change_request');
gr.addQuery("sys_id", source.getValue("u_element_id")).addOrCondition("number", source.getValue("u_element_id"));
gr.query();
if (gr.next()) {
//update fields here as per your requirement
gr.description= source.u_value;
gr.update();
} else {
ignore = true;
}
Create onBefore script in transform map and add below script:
if(action =="insert"){
ignore = true;
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 01:59 AM - edited 10-27-2022 02:32 AM
Tried with above suggested script but it's not coping the data in the target table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 02:35 AM
Can you add below script and let me know what you are getting in logs.
gs.log("initiated the tansform", "updateChange");
gs.log("Element: " + source.getValue("u_element_id") , "updateChange");
var gr = new GlideRecord('change_request');
gr.addQuery("sys_id", source.getValue("u_element_id"));
gr.query();
if (gr.next()) {
gs.log("record found: " + gr.number, "updateChange");
gs.log("Value: " + source.u_value , "updateChange");
//update fields here as per your requirement
gr.description= source.u_value;
gr.update();
} else {
ignore = true;
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 03:55 AM
Now it's printing the logs and copying the data into field but the strange thing is we have three values(entries) with same sys_id's but it's copying only one value in the description field is there any way to copy all the three entries values line by line?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 04:05 AM
just replace
gr.description= source.u_value;
with
gr.description= gr.description + "\n" + source.u_value;
Thank you,
Ali