- 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 04:40 AM
The document id is usually just the sys_id, but it is paired with another field indicating the table. Unfortunately, the name differs from table to table. Look for a field labeled 'table', 'target_table', 'source_table' or something similar. Or if you don't like guessing, look up the dependent field on the document_id dictionary entry for the table in question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 04:59 AM
i have parent_id as a document_id and it depends on parent_table. In which format should I return the value in document_id field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 05:02 AM
The value of the document_id field is a sys_id. The display value is then built using the label of the dependent table field + ':' + display value of the target record with that sys_id in the target table. But when assigning the value to document_id in a script it should just be the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 05:10 AM
so should I return the sys_id of document field of document_id field? I tried this but it is not working.