- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 10:35 PM
Hi,
i have on big Data Source and create a ImportsetTable and a Transform Map.
The Transform Map works with some File Mappings.
Now i want to write Transform Script to fill another Table with Values of these Data Source.
In my opinion i can't use another Transform Map ,because a field on the new table is a reference field to the record from the field mapping and the records are otherwise unrelated.
The only relation ist that the Values are in one Import Record.
E.g.
Table A (Field Mapping):
Record 1
Field 1: String
Field 2: String
Field 3: String
Table B (Gliderecord in Transform Script)
Record 1
Field 1: String
Field 2: String
Field 3: Reference to Table A (Record 1)
Maybe;
Var gr= new GlideRecord(Table B);
gr.initialize();
gr.Field_1 = source.example1;
gr.Field_2 = source.example2;
gr.Field_3 = target.sys_id? (Sys ID of Table A Record?)
gr.insert();
So how ist it possible to set the Field Value of Field 3 in Table B.
The transform logic runs through each record.
But can I intercept the SYS ID of the actual transformation (source table -> target table) in a transform script?
Or do I have to write a script "After" which then runs through the target table and performs the action for each record?
And which Event Name do i have to choose?
onAfter?
target | GlideRecord | The row of the target table that is currently being processed. |
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 10:38 PM
Use onAfter() and target.sys_id- As per the logic you have given- target.sys_id returns the Sys ID of the Table A record and use onAfter() to run the logic after each row transformation into a target record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 10:38 PM
Use onAfter() and target.sys_id- As per the logic you have given- target.sys_id returns the Sys ID of the Table A record and use onAfter() to run the logic after each row transformation into a target record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 10:48 PM
Thank you very much, so I practically answered my own question?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 10:51 PM
Hi,
you can use onAfter transform script for inserting/updating any value in some other target table
This would run on every row being processed
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 01:29 AM
Hi
I have a similar issue I need to update the work notes based on the sys_id from the inserted or the updated record this is my script:
var value = source.u_work_notes;
if(value ==""){
value = "The data has been updated/created through the transform map: "+map.name;
}
var elID = target.sys_id;
gs.info("AZ get SysID Work Notes "+elID);
var glJour = new GlideRecord("sys_journal_field");
glJour.addQuery("element_id", elID);
glJour.addQuery("value", value);
glJour.query();
if (glJour.next()) {
gs.info("Name: " + glJour.element + " Table " + glJour.name + " value " + glJour.value + " sysid " + glJour.sys_id + " element ID " + glJour.element_id);
} else {
gs.info("insert new Val to " + elID);
glJour.element = "u_work_notes";
glJour.name = map.target_table;
glJour.value = value;
glJour.element_id = elID;
glJour.setWorkflow(false);
glJour.insert();
}
I am getting the sys id while I update the record but during a data insert the ID is getting as blank, is there any solution for this?