- 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 05:50 AM
My guess is the issue is in the script include or the sys_id doesn't belong to that table.. Verify that the parent_table field is actually being set to the table you expect and that the sys_id you are using is in that table.
Here is my test that worked as expected:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 05:53 AM
but when I only map to parent table. still it is not showing any data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 05:58 AM
Parent table is a field in it's own right that can be added to the form (see below). Parent Id will not render correctly unless both fields are set correctly but you can add parent table to the form or list to verify just that piece of it. If parent table is set correctly, then your issue will be the sys_id:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 06:23 AM
Just had someone make another suggestion based on an experience they've had in the past with validation that table is set before the id. Can you try moving both mappings into an onBefore script making sure that the table field is assigned before the id field? There is no one of ensuring order with the field mappings. Let me know if that helps. I've never personally run into it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 06:29 AM
i have tried this in transform script on before,
target.parent_table = "kb_knowledge_base";
but it's not working.
in my parent_table field value comes from script include, which is following,
var KBCatTables = Class.create();
KBCatTables.prototype = {
initialize: function() {
},
process: function() {
var result = [];
var dict = new GlideRecord("sys_dictionary");
dict.addNullQuery("element");
var gc = dict.addQuery("name", "kb_category");
gc.addOrCondition("name", "kb_knowledge_base");
dict.orderBy("name");
dict.query();
while (dict.next()) {
result.push("" + dict.name);
}
return result;
}
}