Restart Knowledge workflow using script in servicenow
Whenever an article is created and saved or submitted with a specific SME group the SME group field can be changed, however this change does not trigger a change in workflow for the actual document. It will always remain in the workflow it was first created or saved to.
Solution:-
1.Create a UI Action on "kb_knowledge" table of Button Type.
2. Action Name: republish_knowledge
3.Condition: current.getValue('workflow_state') == 'review'
4.Script:-
current.update();var workflow = new Workflow();
workflow.cancel(current);
var v_grMember = new GlideAggregate('sys_user_grmember');v_grMember.addQuery("group",current.sys_domain);v_grMember.addAggregate("COUNT");v_grMember.query();var answer = "";if (v_grMember.next()) { answer = v_grMember.getAggregate("COUNT"); if (answer > 0){ new KBWorkflow().startWorkflow(current, "workflow"); }}gs.addInfoMessage(gs.getMessage("Workflows for {0} have been re-started", current.getDisplayValue()));
action.setRedirectURL(current);
https://www.servicenow.com/community/developer-articles/restart-knowledge-workflow-using-script-in-servicenow/ta-p/2329848
