
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2024 11:08 PM
Hi!
Would like to ask some help regarding transform map scripting, this is to copy a new data uploaded from source field and target field which is located in another table.
Tried BR and unable to make it work, did some research and found about transform map scripting and I'm still trying to learn it.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 01:03 AM
try this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
/* 1. Get the value of source field */
var sourceValue1 = target.name;
/* 2. Glide record on Table in which you want to update the record */
var gr = new GlideRecord('service_offering');
gr.initialize();
gr.name = sourceValue1 + new GlideDateTime().getLocalDate();
gr.insert();
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2024 11:21 PM
Hello @MarleyB
You will find it in related list of transform map.
You can user onBefore/onAfter script as per your need to update data in another table.
Script :
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
/* 1. Get the value of source field */
var sourceValue1 = source.field1;
/* 2. Glide record on Table in which you want to update the record */
var gr = new GlideRecord('table name');
gr.addQuery('', ''); // your query to update specific record
gr.query();
if (gr.next()) {
gr.field_1 = sourceValue1;
gr.update(); //update record
}
})(source, map, log, target);
Hope this helps...!!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 12:27 AM
Hi Vishal,
Used your scripts and updated based on the source field and target field but not working. Not sure if line 8 is correct for the query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2024 11:35 PM
Hi
(function executeTransformMap(source, map, log, target /*undefined onStart*/ ) {
// Check if the source field has a value
if (source.source_field) {
// Copy the value to the target field
target.target_field = source.source_field;
}
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 01:25 AM
Hi @Harish Bainsla,
This is to copy value to another table and to copy only new record