- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 12:50 AM
Hi,
Please let me know the correction in the script, i have written this script into transform map itself.
if the state is not retired than the import will update matching CI name and class and the target will not overwritten empty value.
(function transformRow(source, target, map, log, isUpdate) {
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 02:01 AM
if you want to ignore the row based on the State, then you should use onBefore transform script and not onAfter
something like this
(function transformRow(source, target, map, log, isUpdate) {
// Add your code here
var name = source.u_ci_name;
var configclass = source.u_ci_class;
if (name == "" || configclass == "") {
ignore = true;
}
var grSource = new GlideRecord("cmdb_ci");
grSource.addEncodedQuery("sys_class_name=" + configclass + "^name=" + name);
grSource.addEncodedQuery("operational_status=6");
grSource.query();
ignore = grSource.hasNext();
})(source, target, map, log, action === "update");
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
08-12-2025 12:57 AM - edited 08-12-2025 12:58 AM
Hi @Deepa12
and what do you want to correct? Have you tried it? Any logs? What does it do and what do you want to do differently? Also please provide more details about the transform script and the whole process
EDIT: I can see that the query is built on name, it shall be on sys ID as the name can be duplicated
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 01:44 AM
Rather than this, create a onBefore Transform script to check for ignore conditions and try it.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 02:01 AM
if you want to ignore the row based on the State, then you should use onBefore transform script and not onAfter
something like this
(function transformRow(source, target, map, log, isUpdate) {
// Add your code here
var name = source.u_ci_name;
var configclass = source.u_ci_class;
if (name == "" || configclass == "") {
ignore = true;
}
var grSource = new GlideRecord("cmdb_ci");
grSource.addEncodedQuery("sys_class_name=" + configclass + "^name=" + name);
grSource.addEncodedQuery("operational_status=6");
grSource.query();
ignore = grSource.hasNext();
})(source, target, map, log, action === "update");
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
08-12-2025 02:06 AM
@Deepa12 ,
Could you please provide the logs or any error details? That would help in understanding and diagnosing the issue more effectively.
Thanks!
Shashank Jain