- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 05:44 AM
In Field Map, in the source table, I have two fields and I want to add two fields and the result comes in the target table
ex: First name & Last Name, both added and results may come in the target table
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 05:52 AM
Hello,
You can either use a field map on one source field (but then check the script box) or use the transform map script (script field right in the center of the transform map itself) and do something like:
//for field map
var string = source.u_first_name.toString() + " " + source.u_last_name.toString();
return string;
//for transform map
var string = source.u_first_name.toString() + " " + source.u_last_name.toString();
target.field_name = string;
The above are examples, please take it from here!
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 05:47 AM
You can create mapping for one of the source field (lets say first name field) with target field. In field map script, you can concatenate first name and second name field and return that value which will get automatically in target table.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 05:52 AM
Hello,
You can either use a field map on one source field (but then check the script box) or use the transform map script (script field right in the center of the transform map itself) and do something like:
//for field map
var string = source.u_first_name.toString() + " " + source.u_last_name.toString();
return string;
//for transform map
var string = source.u_first_name.toString() + " " + source.u_last_name.toString();
target.field_name = string;
The above are examples, please take it from here!
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 05:59 AM
In transform script, you can add below logic
(function transformRow(source, target, map, log, isUpdate) {
target.user_name=source.u_firstname + source.u_lastname;// field name as per your condition
})(source, target, map, log, action==="update");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2022 06:01 AM
Hi,
refer below screen shot on source script you can add the n number of fields based on your requirement.
use source method to get source value.
Example: 1
var fullname = source.u_first_name.toString() + '-' + source.u_last_name.toString();
return (fullname);
Example:2 Source Script: It will return as object. try below
answer = (function transformEntry(source) {
var data = {
'Number': source.u_number + '',
'Order ID': source.u_order_id + '',
'SAP Status Code': source.u_sap_status_code + '',
};
return (JSON.stringify(data));
//return data; // return the value to be put into the target field
})(source);
Result:
{"Number":"CS00944591","Order ID":"5000090","SAP Status Code":"201"}
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar