Knowledge article workflow state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 12:43 AM
Hello Everyone!
I have a requirement like, if a knowledge article is in review state for more than 30 days or 30 days, then the workflow state of the knowledge article should be changed as draft. For this requirement I have written following code in the script action.
var kbaseFlow = new KBWorkflow();
kbaseFlow.progressStatus(current,'draft');
current.u_work_notes = "Article Automatically moved to Draft as pending in review for more than 30 days";
current.update();
But this code only updating the work notes, not changing the workflow state ,
why progressStatus function is not working here , any one can help me?
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:21 AM
Hi @Bharath Reddy M ,
The KBWorkflow().progressStatus() function is used to progress the workflow of a knowledge article to the next state. However, in your case, you want to change the state to a previous state, which is not supported by this function.
To change the workflow state of a knowledge article to a previous state, you can use the setWorkflow(false) method of the GlideRecord object.
Here is an updated code example:
var gr = new GlideRecord('kb_knowledge');
gr.get(current.kb_knowledge);
var reviewDate = new GlideDateTime(gr.sys_updated_on.getDisplayValue());
reviewDate.addDaysLocalTime(-30);
var currentDate = new GlideDateTime();
if (gr.workflow_state == 'review' && reviewDate.before(currentDate)) {
gr.workflow_state = 'draft';
gr.u_work_notes = "Article Automatically moved to Draft as pending in review for more than 30 days";
gr.setWorkflow(false);
gr.update();
}
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 03:24 AM
Hello I PDI Knowledge article workflow states 7 are available in my dev environment only 5 states are available.Do you know the reason for this case. Plugin also activated (knowledge article advanced
Please suggest me