- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 03:09 AM
I have a requirement to retire all child articles (translated versions) when the parent workflow_state is set to retired by using the UI action for Retire. But I cannot seem to find a way to change the workflow state for the child articles.
The Knowledge Base follows Instant Retire Workflow-
I've tried creating a Business Rule to set the workflow state to Retired when a parent updates. Didn't change the workflow state.
I've tried using Flow Designer to create a simple flow that triggers when a record is updated to Retired, that does a look up to find records that has the trigger record as a parent and then attempts to update the field workflow_state to Retired.
Lastly I tried to add a Run Script stage to the Instant Retire workflow in the workflow editor, but I couldn't get that to work either.
Is this something to do with it being the workflow_state field that needs to be changed? What is the best practice to deal with such a requirement? I'm out of options right now.
They have around 6 000 articles in the Knowledge Base in question and this should apply to all of them, when the parent articles is retired.
Thank you,
Vikram Kee Damslora Willoch
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 09:12 AM
It's okay, I found the mistake. Because of different support in functionality on the version of the knowledge base, (2 and 3) I had to put it so the retire workflow is triggered in the script on the child articles.
var gr = new GlideRecord("kb_knowledge");
gr.addQuery("parent", current.sys_id);
gr.query();
while (gr.next()) {
new KBWorkflow().startWorkflow(gr, "retire_workflow"); //This is the added line
//gr.setValue("workflow_state", "retired");
//gr.update();
}
Taken straight from the Retire UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 03:17 AM
Hi
Hi OOB servicenow works like the below
- An article and its translations have a parent-child relationship. Retiring a parent article does not automatically retire all its translated child articles.
Refer document here
https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/product/knowledge-management/concept/c_RetiredKnowledgeArticles.html
You can have a custom BR on Knowledge table before update
Script:
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('parent',current.sys_id); // check parent sysid of all child articles
kb.query();
while(kb.next())
{
kb.workflow_state = 'retired'; // retire all child articles matching with parent
kb.update();
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 03:56 AM
Hello Sandeep
I tried a business rule with that very code, but it didn't work. I tried it again now, and the translated versions of the parent article are still not in the retired state.
These are the conditions, which sets it to only occur for a certain HR knowledge base and to trigger when the record goes into retired state, is that correct?
The advanced tab has the script you provided and the actions tab doesn't have anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 08:12 AM
Hi
Try without the conditions and just the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 09:12 AM
It's okay, I found the mistake. Because of different support in functionality on the version of the knowledge base, (2 and 3) I had to put it so the retire workflow is triggered in the script on the child articles.
var gr = new GlideRecord("kb_knowledge");
gr.addQuery("parent", current.sys_id);
gr.query();
while (gr.next()) {
new KBWorkflow().startWorkflow(gr, "retire_workflow"); //This is the added line
//gr.setValue("workflow_state", "retired");
//gr.update();
}
Taken straight from the Retire UI action