Transform map on Hardware Asset Department
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I'm trying to import set to set the department field on the alm_asset table. My data sources only contains the assigned_to. How can I set the department by referencing the assigned_to.department?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hi @athavichith,
For this use case you can use field map script option,
1)Create a new field map, Check the use source script checkbox
2)Target field will be Department, target table would be alm_asset
3)Write a script, Here is pseudo code:
var assignedTo = source.u_assigned_to;
var deptId = "";
if (assignedTo) {
var userGr = new GlideRecord('sys_user');
userGr.addQuery('sys_id', assignedTo);
userGr.query();
if (userGr.next()) {
deptId = userGr.department + "";
}
}
return deptId;
if you find this answer useful, mark it as helpful/solution accepted.
Thanks and Regards,
Mohammed Zakir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43m ago
We ran into this issue. We have assets that are assigned via ServiceNow flows, assigned via swapping in an INC, and even manual issuances. We ended up making a business rule that pulled the department from the user when the 'assigned_to' attribute is changed. This makes sure that no matter what sets the assignment, it pulled the department. If you go this route, you just need to enable running business rules on your transform map.
