- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 03:34 PM
Can I append a target field in a transform? I have files being imported to a table and it can affect the same field multiple times.
I was trying: "target.field = target.field + source.field" but that doesn't seem to work.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2017 06:24 PM
Hey Kkim,
I also tried to do the way you were trying to achieve and i was able to get the value in logs but was not able to append in table.
I believe it will not work in this way. In transform map source field you need to do GlideRecord, I tried to send incident short_description and it worked in this way. Please glide the record based upon you coalesce field.
Please find the sample code below:
answer = (function transformEntry(source) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('incident', source.u_number); // pass the source coalesce field
gr.query();
if(gr.next())
{
var val = gr.short_description + ' ' + source.u_short_description;
return val; // return the value to be put into the target field
}
})(source);
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 05:29 PM
Can you please try in this way, see if this helps.
var target_val = target.getValue('field_name');
target_val += source.field;
target.field = target_val;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2017 03:40 PM
I played with it using an onAfter script instead of the direct field map but no luck. I get a null value for the first portion:
var targetValue = target.getValue('u_field');
targetValue += source.u_field;
target.u_field = targetValue;
target.update();
Result: null123456

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2017 06:24 PM
Hey Kkim,
I also tried to do the way you were trying to achieve and i was able to get the value in logs but was not able to append in table.
I believe it will not work in this way. In transform map source field you need to do GlideRecord, I tried to send incident short_description and it worked in this way. Please glide the record based upon you coalesce field.
Please find the sample code below:
answer = (function transformEntry(source) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('incident', source.u_number); // pass the source coalesce field
gr.query();
if(gr.next())
{
var val = gr.short_description + ' ' + source.u_short_description;
return val; // return the value to be put into the target field
}
})(source);
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 03:40 PM
Thanks. That did the trick.