Transform Map issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
Hello All,
i have a excel sheet data with updatedgroupname and existinggroupname values.
i need to update the data existinggroupname is coelece so that it wont create updated fileds also i have created one on before script to do the name change.
The issue is group name is not updating.
@Ankur Bawiskar any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
updating a coalesce field is not a good practice because that's the primary identifier for the system to determine if insert/update happens.
-> Don't use any field map
-> in excel have 2 columns, existing group, new group
-> use onBefore transform script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", source.u_existing_name);
gr.query();
if (gr.next()) {
gr.name = source.u_updated_name;
gr.update();
}
ignore = true;
})(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
2 hours ago
Hello @Ankur Bawiskar ,
If the record is not present then i need to create a record in the group table with the new name also that's why i have used field map and also i have other fields too to map around 3-4 fields also i have roles record also to be created if not present in the sysgroup_has_role table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I will still recommend not to use onBefore since you are trying to update coalesce field
in onBefore handle the insert logic along with other fields
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", source.u_existing_name);
gr.query();
if (gr.next()) {
gr.name = source.u_updated_name;
gr.update();
}
else{
// creation logic and role logic
}
ignore = true;
})(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
an hour ago
okay so i will remove the filed mappings and coalesce and will update from there on before script itself my understanding is correct right?
