Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

ITSM

KritiK
Tera Contributor

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

@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.

Not applicable

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.