- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 04:19 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 06:53 AM
I'm not certain why we are calling the script include and querying the dictionary at all as we already know the tables because they are being used to generate the query. If the intent is that I don't know what table my id is for so I want it to try multiple tables then you can do something like the following untested script:
var tables = ['kb_category','kb_knowledge_base'];
var id = "25cd15c3ac6c728056e1781325626541";
for (var i = 0; i < tables.length; i++) {
var gr = new GlideRecord(tables[i]);
if (gr.get(id)) {
target.parent_table = tables[i];
target.parent_id = id;
break;
}
}
But if you know the table, it should be as simple as:
target.parent_table = "kb_knowledge_base";
target.parent_id = "25cd15c3ac6c728056e1781325626541";
In either case, I would remove the field mapping entries in favor of the on before script to guarantee ordering.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 06:40 AM
So your script include returns an array? Do you reduce it down to 1 string representing a table name somewhere?
You cannot set the parent_table field to multiple values as the sys_id can only exist in 1 table, so without some more to get it down to 1 value it will fail.
Also, the intent of the previous post was to get you to try the following to ensure the ordering. This assumes that the sys_id represents a record in that table. If it's a category, it will not work.
target.parent_table = "kb_knowledge_base";
target.parent_id = "25cd15c3ac6c728056e1781325626541";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 06:44 AM
so what should I do now? should I call script include in to my field mapping script and access its index?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 06:53 AM
I'm not certain why we are calling the script include and querying the dictionary at all as we already know the tables because they are being used to generate the query. If the intent is that I don't know what table my id is for so I want it to try multiple tables then you can do something like the following untested script:
var tables = ['kb_category','kb_knowledge_base'];
var id = "25cd15c3ac6c728056e1781325626541";
for (var i = 0; i < tables.length; i++) {
var gr = new GlideRecord(tables[i]);
if (gr.get(id)) {
target.parent_table = tables[i];
target.parent_id = id;
break;
}
}
But if you know the table, it should be as simple as:
target.parent_table = "kb_knowledge_base";
target.parent_id = "25cd15c3ac6c728056e1781325626541";
In either case, I would remove the field mapping entries in favor of the on before script to guarantee ordering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 11:03 PM
its working now. thanks