Need help in Transform Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 12:37 AM
I'm new to CMDB data loading, I was working on data load using excel.
I see there are few reference fields in excel[Assigned to, Company], but instead of sys_id, the display value of the names are given.
How to convert those update those Assigned to and Company fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 12:41 AM
Hi @Admin7267 ,
You can refer below link where u can achieve this requirement with no scripting
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 01:14 AM - edited 02-05-2024 01:16 AM
Hello @Admin7267 ,
use Below script which will resolve your query.
use onbefore event script
var assignedTo = new GlideRecord('sys_user');
assignedTo.addQuery('name', source.u_assigned_to);
assignedTo.query();
if (assignedTo.next()) {
target.u_assigned_to = assignedTo.sys_id;
}
// Get the sys_id for the "Company" field
var company = new GlideRecord('core_company');
company.addQuery('name', source.u_company);
company.query();
if (company.next()) {
target.u_company = company.sys_id;
}
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers!
Thanks and Regards,
Abhijeet Pawar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 01:45 AM
Hi @Admin7267 ,
Refer below link
https://www.servicenow.com/community/developer-forum/transform-script-for-reference-field/m-p/207635...
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand