Publish knowledge article on submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 12:29 AM
Hi, I want my knowledge article to go through the publish workflow when I press submit, and remove the publish button. My idea was to write a client script that calls a script include, but it's not working. Can anyone help please? 🙂
I also tried using a business rule also with no luck.
the scripts:
client:
function onSubmit() {
var ga = new GlideAjax('workflow_knowledge');
ga.addParam('sysparm_name', 'run_workflow');
ga.addParam('sysparm_recordTable', 'kb_knowledge');
ga.getXMLAnswer();
}
server: The function that runs on the Publish UI Action.
var workflow_knowledge = Class.create();
workflow_knowledge.prototype = Object.extendsObject(AbstractAjaxProcessor, {
run_workflow: function(){
if(new KBKnowledge().canPublish(current)){
var preValue = current.workflow_state + ' ';
if (current.kb_knowledge_base.kb_version == "3" && new KBWorkflow().startWorkflow(current, "workflow")) {
if (current.workflow_state != 'publish';{
current.update();
}
var knowledge = new GlideRecord("kb_knowledge");
if(knowledge.get(current.sys_id && preValue != knowledge.getValue("workflow_state)){
gs.addInfoMessage(new KBKnowledge().getStateMessage(knowledge.getValue("workflow_state")));
}
} else if (current.kb_knowledge_base.kb_version == "2") {
current.workflow_state = 'published';
current.update();
gs.addInfoMessage(new KBKnowledge().getStateMessage(current.getValue("workflow_state")));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 01:16 AM
Hi @Snow Tomcal ,
Did you select proper knowledge base while creating article ? We have to mentioned workflow at the knowledge based level separately.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 01:22 AM
Yes, the specific knowledge base looks just like that 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 01:21 AM - edited 11-14-2022 01:23 AM
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 01:26 AM
Hi @Snow Tomcal ,
Is there any modification on that workflow happened ? or is there any Business rules which are triggering to set the workflow state? Please check that.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 01:37 AM
Hi, can't find any business rules, tried to write logs, one when the business rule is triggered and another when the ui action is triggered and another when the workflow is triggered.
the UI action and workflow were not triggered.