- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 12:02 PM
Hi I I' trying to update data in Company[core_company] table. I'm using excel sheet to upload the data and update it.
My excel sheet has two columns
1) Name: String value. will be used as coalesce.
2) Manufacturer: String value. T or F
I've created a transform map and mapped both field to core company fields:
Name -> Name
Manufacturer -> Manufacturer
Manufacturer field is in core_company table is True/False field i.e. checkbox and my sheet has Manufacturer value as T/F so I've written a transform script to transform T/F in True/False.
But it is not working, all my records are getting ignored.
Below are the different versions of transform script I have used.
1)
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(source.u_manufacturer == 'T'){
gs.log('HKXXX true'+ source.u_manufacturer);
return 'TRUE';
}
else{
gs.log('HKXXX false'+ source.u_manufacturer);
return 'FALSE';
}
})(source, map, log, target);
2)
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(source.u_manufacturer == 'T'){
gs.log('HKXXX true'+ source.u_manufacturer);
return true;
}
else{
gs.log('HKXXX false'+ source.u_manufacturer);
return false;
}
})(source, map, log, target);
None of them work, I can see the logs in the system logs, but manufacturer values are not getting changed. All records are getting ignored.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 12:14 PM
Hi @HrishabhKumar ,
1.Script Placement
Make sure your script is placed in the Field Map's "Script" field, not in the "Transform Map Script" unless you're doing something more complex. Since you're transforming a single field (Manufacturer), the script should be in the Field Map for Manufacturer.
2. Correct Return Type
Checkbox fields in ServiceNow expect a boolean value (true or false), not strings like 'TRUE' or 'FALSE'.
So this field map script is correct:
(function runTransformScript(source, map, log, target) {
if (source.u_manufacturer == 'T') {
return true;
} else {
return false;
}
})(source, map, log, target);
Also, make sure you coalesce on name or another field you think it is unique.
Mark this as helpful and correct, if this solves your issue.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 12:14 PM
Hi @HrishabhKumar ,
1.Script Placement
Make sure your script is placed in the Field Map's "Script" field, not in the "Transform Map Script" unless you're doing something more complex. Since you're transforming a single field (Manufacturer), the script should be in the Field Map for Manufacturer.
2. Correct Return Type
Checkbox fields in ServiceNow expect a boolean value (true or false), not strings like 'TRUE' or 'FALSE'.
So this field map script is correct:
(function runTransformScript(source, map, log, target) {
if (source.u_manufacturer == 'T') {
return true;
} else {
return false;
}
})(source, map, log, target);
Also, make sure you coalesce on name or another field you think it is unique.
Mark this as helpful and correct, if this solves your issue.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 12:33 PM - edited 06-25-2025 12:34 PM
Hi @HrishabhKumar
The script you are using is transform script
so you have to set it like this
if(source.u_manufacturer == 'T'){
gs.log('HKXXX true'+ source.u_manufacturer);
target.field_name = true;
}
else{
gs.log('HKXXX false'+ source.u_manufacturer);
target.field_name = false;
}
The script logic you used works in field mapping script
like from source field script, return true and field set in target field like this