Update assigned to field using transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 12:59 PM
Hi,
I have created a transform map to update assigned to field in one of my custom table. created field mapping for the same and assigned to updated correctly.
Now i want to restrict if the mentioned user is part of the assignment group then only it should update the assigned to field. if the mentioned user is not part of assignment group, it should ignore.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 03:13 PM
Hi @ram11vrnr ,
To restrict the update of the "assigned to" field based on the user's membership in the assignment group, you can add a script include that checks if the user is a member of the group before updating the field. Here's an example:
- Create a script include with the following code to check if the user is a member of the assignment group:
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
initialize: function() {
},
isUserMemberOfGroup: function(userId, groupId) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group', groupId);
gr.query();
return gr.hasNext();
}
}
This script include defines a method isUserMemberOfGroup that takes a user ID and a group ID as parameters, and checks if the user is a member of the group by querying the sys_user_grmember table.
- In the field mapping for the "assigned to" field in the transform map, add a script to call the isUserMemberOfGroup method and update the field only if the user is a member of the assignment group. Here's an example:
// Instantiate the script include
var scriptInclude = new MyScriptInclude();
// Get the user ID and assignment group ID from the source field values
var userId = source.u_user.toString();
var assignmentGroupId = source.u_assignment_group.toString();
// Check if the user is a member of the assignment group
if (scriptInclude.isUserMemberOfGroup(userId, assignmentGroupId)) {
// Update the target field with the user ID
target.assigned_to = source.u_user;
}
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar