Transform Map issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello All,
I have created a transform map for group table created the name field as coelesce and also transformed it it successfully created records everything is fine leaving one thing.
there is a type field which is a list collector in sys_user_group table when i transformed the excel sheet it created some duplicate values in "sys_user_group_type" as incident,change,request etc we already have incident,change,request wtc out of box values how this duplicate value creation can be avoided also it should map the existing correct group types.
one row example of my excel sheet.
| Name | Type | Line Vendor/manager | Description | Group email |
| Test | incident,change | Debasis | test description | test@group.com |
@Ankur Bawiskar any suggestions?
@
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
then handle using transform onBefore script
Remove the field map for that Type field
something like this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// your existing logic
// handle list logic here
var arr = [];
var incomingType = source.u_type.toString();
var gr = new GlideRecord("sys_user_group_type");
gr.addQuery("name", "IN", incomingType);
gr.query();
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
target.type = arr.toString();
})(source, map, log, target);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
Hello @Ankur Bawiskar ,
i tried the on before script
The type filed in group records are now blank no values in it.
Note:My group types contains multiple values like incident,change,problem and in some records only incident below is example:
| Name | Type | Line Vendor/manager | Description | Group email |
| Test | incident,change | Debasis | test description | test@group.com |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
did you debug what came in that array?
basically it will search that group type table with those names
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// your existing logic
// handle list logic here
var arr = [];
var incomingType = source.u_type.toString();
var gr = new GlideRecord("sys_user_group_type");
gr.addQuery("name", "IN", incomingType);
gr.query();
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
gs.info("Type array is" + arr.toString());
target.type = arr.toString();
})(source, map, log, target);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello @Ankur Bawiskar
the array log is coming blank but i checked the incoming type it is coming like below for different different records
incident.request,problem,chnage
incident,request
change,problem
like the above that's why i think its not finding individual type records in the add query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
the addQuery is using IN operator so it should be able to search in the name field
Did you try searching directly in group type table if those records are present?
share screenshots.
if they are then logic I shared will work for sure.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
