- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 02:26 AM
Hi,
I am trying to transform data with the below format. Is there a way to script in the previous records name, if the current record name is null during a transform?
Example:source table
Result:target table
it will a very helpfull thanks
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 03:19 PM
Hi,
Use an onStart Transform script with the following code:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var tmpName = '';
var sourceTable = map.source_table;
var importSet = import_set.sys_id;
var sourceGR = new GlideRecord(sourceTable);
sourceGR.addQuery('sys_import_set', importSet);
sourceGR.orderBy('u_value1');
sourceGR.query();
while (sourceGR.next()) {
if (sourceGR.u_name != 'null') {
tmpName = sourceGR.u_name.toString();
} else {
sourceGR.setValue('u_name', tmpName);
sourceGR.update();
}
}
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:37 AM
You can use some thing like this in your "onBefore" Transform Script
if ((action == 'insert' || action == 'update') && source.Name == null)) ignore = true;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:53 AM
Hi,
try this
if( source.u_name == 'null'|| source.u_name == null)
ignore = true;
Regards
Ankud
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 03:19 PM
Hi,
Use an onStart Transform script with the following code:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var tmpName = '';
var sourceTable = map.source_table;
var importSet = import_set.sys_id;
var sourceGR = new GlideRecord(sourceTable);
sourceGR.addQuery('sys_import_set', importSet);
sourceGR.orderBy('u_value1');
sourceGR.query();
while (sourceGR.next()) {
if (sourceGR.u_name != 'null') {
tmpName = sourceGR.u_name.toString();
} else {
sourceGR.setValue('u_name', tmpName);
sourceGR.update();
}
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 12:46 AM
perfectly working thank you thank you