map the fields present in child table thrgh transform script if the transform map is on parent table

SK41
Giga Guru

Hi,

 

I have a requirement where the transform map runs on network gear table, and there are two fields " hardware os" & "hardware version", which are in IP Firewall table only, which is the child table of network gear table. 

I need to map these two values in child table coming through through transform map.

whenever the class is firewall the record gets created in ip firewall table through transform map, how can i map these two fields in child table through transform scripts when ever the record comes for firewall.

 

Is there any other way also to map these fields?

Kindly, assist!

 

Thanks!

2 REPLIES 2

Sai Kumar B
Mega Sage
Mega Sage

@SK41 

You can write an onAfter() transform script to map the target record values with the IP Firewall table fields.

For more information - https://docs.servicenow.com/bundle/tokyo-platform-administration/page/script/server-scripting/refere... 

 

If I could help you with my response you can mark it as helpful and correct as it benefits future viewers
Thanks,
Sai Kumar B
Community Rising Star 2023 & 2022

SK41
Giga Guru

hi,

i wrote below code in onafter transform script, it is working but it is alo creating one extra empty record in ip firewall table also, which should not happen.

 

if ((source.u_device_type == "Firewall") && (source.u_hardware_os != '' || source.hardware_os_version != ''))
{
var gr = new GlideRecord('cmdb_ci_ip_firewall');
gr.get(target.sys_id);

gr.setValue('har_os', source.u_hardware_os);
gr.setValue('os_version', source.u_hardware_os_version);
gr.update();

 

could you plsese suggest how to fix it?

Thanks!