- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 01:34 AM
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;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 12:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 02:25 AM
Hi,
If you want to do this I think you need to specify the target class as well:
target.sys_class_name = 'cmdb_ci_db_mssql_database';
and target.cmdb_ci_db_mssql_database.tcp_port = source.u_server_port; (i've removed the ref_)
Regards
Arnaud
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 03:38 AM
Hi Arnuad,
Thanks for your response!!
I tried the solution but the issue still exists.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 04:05 AM
Your transform map is targeting cmdb_ci.
Do you map things into different classes or everything should go to cmdb_ci_db_mssql_database ?
if everything should go to cmdb_ci_db_mssql_database then you can change the target table of your transform map to this class instead of cmdb_ci. You can then use the standard field mapping.
Otherwise in your transform map, use Run script and put the code here, not in the field mapping. You'd have to enclose the 2 lines between a if so it will only apply to import record you want to map to "cmdb_ci_db_mssql_database". For testing purpose you can put the 2 lines without enclosing into the if statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2022 12:16 AM - edited 10-21-2022 03:13 AM
Hi Arnaud,
Everything should go to 'cmdb_ci' and based on the child class passed in the Payload the validations should happen. As of now, I have enabled insert and update only for 'cmdb_ci_db_mssql_database' but in near future more classes will be added so the target table has been configured as cmdb_ci'.
On the field mapping level, I had tried selecting 'cmdb_ci_db_mssql_database' as target table but it did not helped.
Also, as per your suggestion I tried executing the 2lines of code in the Run Script but no luck!!