Need help with transform map script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 06:58 AM - edited 10-17-2024 06:59 AM
Hi Team,
I am doing transformation of data for one of our monitoring tools which is creating incidents in servicenow.
I need to use data stored in staging table to calculate Configuration item and assignment group of Incident.
We have field called "Tags" in staging table which has below data:
Hostname:NAP01-OND02,Vitality:V0,Support Team:Real Time Applications,Application Name:EDS
So Configuration item on Incident should be NAP01-OND02. If this does not exist in CMDB then it should be "CI NOT Present".
Assignment group = Real Time Applications. If assignment group is not found in group table, then populate with CI.support group.
How shall i parse this value and write glide query to populate CI and AG on incident record by creating respective field maps.
Appreciate your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 07:54 AM
Hi @dvelloriy ,
You can use below code to do the mapping in your transform map script.
var str = source.u_tag;
//'Hostname:NAP01-OND02,Vitality:V0,Support Team:Real Time Applications,Application Name:EDS';
var arr = str.split(',');
var ci = arr[0].split(':')[1];
var suppG = arr[2].split(':')[1];
var incGr = new GlideRecord('incident');
incGr.addQuery('cmdb_ci', ci);
incGr.query();
if (!incGr.next())
ci = 'CI NOT Present';
var grpGR = new GlideRecord('sys_user_group');
grpGR.addQuery('name', suppG);
grpGR.query();
if (!grpGR.next()){
var cmdbGr = new GlideRecord('cmdb_ci');
cmdbGr.addQuery('cmdb_ci', ci);
cmdbGr.query();
if (cmdbGr.next())
suppG = cmdbGr.support_group;
}
target.ci = ci;
target.assignment_group = suppG;
Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:08 AM
Thanks Runjay. One query, why are we querying Incident table below? I think we should query cmdb_ci table. Please advise.
var incGr = new GlideRecord('incident'); incGr.addQuery('cmdb_ci', ci); incGr.query(); if (!incGr.next()) ci = 'CI NOT Present';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 09:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2024 10:54 PM
Hi @dvelloriy ,
Let me know if still facing any issue.
Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.