Need to update the Dot walking field on the target table via transform map source field

SAS21
Tera Guru

Source File has a field Vendor id and mapping this field to a dot walking field on the target table. 

Here is the script i am trying in onbefore. After running the transform the value of the target field is empty.

Pls suggest

 

if (source.u_cmp_vendor_id_l3 != '') {
var vndID = new GlideRecord('core_company');
vndID.addQuery('u_number', source.u_cmp_vendor_id_l3);
vndID.query();
if (vndID.next()) {
target.x_cy_tr_entity_new_name.u_number.setDisplayValue(source.u_cmp_vendor_id_l3);
} else {
log.warn('Vendor id not found');
}
}

1 ACCEPTED SOLUTION

3 REPLIES 3

Nilesh Pol
Tera Guru

@SAS21 Your OnBefore Script runs before the actual transformation occurs, so it’s likely not correctly assigning the reference value to the target field. 

just verify with following script: 

if (!gs.nil(source.u_cmp_vendor_id_l3)) {
var vndID = new GlideRecord('core_company'); // Check if this is the right table
vndID.addQuery('u_number', source.u_cmp_vendor_id_l3); // Match Vendor ID
vndID.query();

if (vndID.next()) {
target.x_cy_tr_entity_new_name = vndID.sys_id; // Assign sys_id, not setDisplayValue
} else {
log.warn('Vendor ID not found: ' + source.u_cmp_vendor_id_l3);
}
}

 

@Nilesh Pol  Thank you, it worked

Nilesh Pol
Tera Guru

@SAS21