- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 12:11 AM
Hi,
I need to create new Knowledge Category by setting Parent ID field in kb_category table using a scheduled job script.
I have the sys_id's of the both main and sub category fields.
Main Category in kb_knowledge_base table is IT Operations, sys_id c8c0005fdb947a84f6ef7016bf9619b9
Sub Category in kb_category table is Application Summaries/Runbooks, sys_id 673ee506db9cbb886e206154ca9619c7
I used below script to set the value in Parent ID field but it updating as empty only...
var new_cat = new GlideRecord('kb_category');
new_cat.initialize();
new_cat.label = "*****";
new_cat.value = "*****";
new_cat.parent_id.sys_id = "673ee506db9cbb886e206154ca9619c7";
//new_cat.setValue('parent_id', '673ee506db9cbb886e206154ca9619c7');
new_cat.setValue('table_name', 'kb_category');
//new_cat.setDisplayValue('parent_id','Knowledge Category: Application Summaries/Runbooks');
new_cat.active = 'true';
new_cat.insert();
Can anyone help, how to set Parent ID field using a script in Scheduled Job?
Thanks in Advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 12:35 AM
The below script is working fine for updating parent ID field in the Knowledge Category table
var new_cat = new GlideRecord('kb_category');
new_cat.initialize();
new_cat.label = "*****";
new_cat.value = "*****";
new_cat.parent_table = 'kb_category';
new_cat.parent_id = '673ee506db9cbb886e206154ca9619c7'
new_cat.active = 'true';
new_cat.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 12:50 AM
Hi, I would have thought creation of a new ‘unique’ Knowledge Category was a 1 off non reoccurring event and so the need to use a scheduled job seems unusual.
Is your new kb_category record created from your code without the parent_id or not created at all?
parent_id = ‘your_sys_id’; is probabaly thre way I'd try to apply it, have you confirmed it’s the correct sys_id?
Perhaps try manually creating a record and once saved you can validate your values by looking at the xml.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 12:58 AM
Hi,
kb_category record is creating using the scheduled job script, that is working fine. But only the parent ID field is not updating
I tried below code, but this also not working
new_cat.parent_id= '673ee506db9cbb886e206154ca9619c7';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 12:35 AM
The below script is working fine for updating parent ID field in the Knowledge Category table
var new_cat = new GlideRecord('kb_category');
new_cat.initialize();
new_cat.label = "*****";
new_cat.value = "*****";
new_cat.parent_table = 'kb_category';
new_cat.parent_id = '673ee506db9cbb886e206154ca9619c7'
new_cat.active = 'true';
new_cat.insert();