transform script to populate target field with value from source field

nomadie
Kilo Expert

Hi there..need guidance of this project requirement.

If value from the source file is found in the target field reference type, it updates the target field. Else, the source value is ignored.

Sample data 

S/N             # of depr yrs
SN1234      3 <wrong value>
SN4566      SL 3 Years <correct value>

Expected Result
ignore the first record
insert/update the second record

I've tried adding my script with this 4 scenarios.

Tranform Row WITH the fields mapped, choice action is ignore.
*Failed Result - everything were ignored.
Tranform Row WITH the fields mapped, choice action is create
*Failed Result - existing value updates the field, however, it insert new value to the reference table (expected is ignored)

//Update Depreciation
var gr = GlideRecord('cmdb_depreciation');
gr.addQuery(source.u___of_depr_yrs,g_form.getValue('name'));
gr.query();
if(gr.next()){
target.depreciation = gr.getDisplayValue('name');
}

Transform Row WITHOUT the fields mapped
*Failed Result - everything were ignored.

//Update Depreciation
var gr = GlideRecord('cmdb_depreciation');
gr.addQuery(source.u___of_depr_yrs,g_form.getValue('name'));
gr.query();
if(gr.next()){
target.depreciation = gr.getDisplayValue('name');
choice_action = ignore;
}

Created a filled map script.
*Failed Result - everything were ignored.

var gr = GlideRecord('cmdb_depreciation');
gr.addQuery(source.u___of_depr_yrs,g_form.getValue('name'));
gr.query();
if(gr.next()){
answer = gr.getDisplayValue('name');
}

If anyone can help me with this since I am stuck with this 1 field.

2 REPLIES 2

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

You can use Two coalesce in this case one on S/N and other on Depreciation field.

 

Thanks,
Ashutosh Munot

nomadie
Kilo Expert

Thanks no need to add script but rather map and choice action = reject. Thank you all.