Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to dot walk child table's fields in field map?

Ankita9
Tera Contributor

Hi All,

 

I want to dot walk to map fields of "MS SQL Database" table which is a child table of CMDB CI. 

There are few text fields "Server port, ucmdb model, Maintenance Window Info,  Patch Group, Next refresh" which are child class specific.  I tried using "source script" but no luck. Please suggest.

 

Source Script : target.ref_cmdb_ci_db_mssql_database.tcp_port = source.u_server_port;

 

Ankita9_1-1666254547894.png

 

1 ACCEPTED SOLUTION

Arnaud Derancou
Kilo Guru

Hi,

 

Please try with :

target.sys_class_name = 'cmdb_ci_db_mssql_database';

target.tcp_port = source.u_server_port;

 

I'd expect this to work.

 

if this is not working you can add "On after" script and do a glideRecord on the target table with "target.sys_id" and update the field like this, but that will trigger a second update so option 1 is preferred.

 

var gr=new GlideRecord('cmdb_ci_db_mssql_database');

if (gr.get(target.sys_id)) {

gr.tcp_port = source.u_server_port;

gr.update();

}

 

Regards

Arnaud

View solution in original post

5 REPLIES 5

Arnaud Derancou
Kilo Guru

Hi,

 

Please try with :

target.sys_class_name = 'cmdb_ci_db_mssql_database';

target.tcp_port = source.u_server_port;

 

I'd expect this to work.

 

if this is not working you can add "On after" script and do a glideRecord on the target table with "target.sys_id" and update the field like this, but that will trigger a second update so option 1 is preferred.

 

var gr=new GlideRecord('cmdb_ci_db_mssql_database');

if (gr.get(target.sys_id)) {

gr.tcp_port = source.u_server_port;

gr.update();

}

 

Regards

Arnaud