ITSM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 11:47 AM
how to update a reference field of a target table if short description of target table contains a number of source table using transform map.
if anyone knows please let me know quickly
6 REPLIES 6

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 08:47 AM
@KritiK Please try the following script, and see if it works.
onBeforeTransform(sourceRecord, targetRecord, context)
{
var sourceNumber = sourceRecord.u_number;
gs.info("Number: " + sourceNumber);
var shortDescription = targetRecord.short_description;
gs.info("short description: " + shortDescription);
if (shortDescription && shortDescription.includes(sourceNumber.toString()))
{
gs.info("check if condition: " + shortDescription && shortDescription.includes(sourceNumber.toString()));
var grUser = new GlideRecord('sys_user');
grUser.addQuery('user_name', sourceRecord.PRID_requested);
grUser.query();
if (grUser.next()) {
targetRecord.u_requested_for = grUser.getValue('sys_id');
gs.info('testing'+sourceRecord.PRID_requested);
}
}
else {
context.abortAction();
}
Hope this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 12:12 PM
Hello @KritiK ,
If you need to update the reference field so instead of passing the display value you should pass the sys_id of that record then only the reference field will mapped.
Please hit on the helpful button.
Thank you.