Parse a string after ' : ' and assign the value to reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 10:51 AM
Hi All,
We have a requirement to parse a string after ':' and we need to assign the value after ':' to a reference field called 'server' in cmdb_ci_db_instance .
To be more clear, we get the HOSTNAME in the source field as "ORACLE:CNSZIDC04" . We need to parse after ':' and take the value after that and assign to a field called Server.
We are planning to write a OnAfter transform script for this. Please guide how to parse and take the value to the right side of ':'. Please note the Target field is Reference field . Please guide.
CODE:
============
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var shnm = source.u_hostname;
var scinm = source.u_cinum;
var pse = shnm.split('\:');
var str1 = pse[0]+':'+pse[1];
var grd = new GlideRecord('cmdb_ci_db_instance');
grd.addQuery('u_maximo_uid', 'scinm');
grd.query();
if(grd.next()){
grd.u_server = pse[1].sys_id;
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 11:19 AM
Hi,
I am not able to use field mapping sourec script as I cannot see the 'Server' reference field in my Target table mentioned in Transform Map.
Please suggest.How can do this In Transform Script.