transform script to populate target field with value from source field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2018 08:04 PM
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.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2018 12:37 AM
HI,
You can use Two coalesce in this case one on S/N and other on Depreciation field.
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 03:38 AM
Thanks no need to add script but rather map and choice action = reject. Thank you all.