- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2018 10:01 AM
Hi Every One ,
Brand new KB Article: Goes through KBApprove workflow.
Upon close of KBApprove, Employee Knowledge workflow starts.
User clicks UI Button to "Republish":
Cancel the Employee Knowledge workflow and start the KBApprove workflow.
Upon close of KBApprove workflow, a new Employee Knowledge workflow starts.
Issue : when i click on "Republish button" it is creating new KbApprove workflow, when KB APProve is Activated then earlier created Employee KB workflow is to be deleted in Workflow Context , but it is still running, i just want to delete that Second workflow-Employee KB from workflow Context. and Once i Published KB record then KBAprove is finished that time only Employee KB Should come to Active state.
Employee Knowledge -workflow
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 08:13 PM
Ok. Great. So this should work all fine. This should be at the beginning of the KB Approval workflow
var wf =new GlideAggregate('wf_context');
wf.addEncodedQuery('workflow_versionLIKEKB approval V2^active=false^id='+current.sys_id);
wf.addAggregate('COUNT');
wf.query();
var wcounts =0;
var deletecount = 0;
if(wf.next())
wcounts = wf.getAggregate('COUNT');
var inc= new GlideRecord('wf_context');
inc.addEncodedQuery('workflow_versionLIKEKB approval V2^active=false^id='+current.sys_id);
inc.orderBy('sys_created_on');
inc.query();
while(inc.next())
{
deletecount = deletecount++;
if (deletecount<wcounts)
inc.deleteRecord();
}
GlideRecord('wf_context');
inc.addEncodedQuery('workflow_versionLIKEEmployee Knowledge^id='+current.sys_id);
inc.orderBy('sys_created_on');
inc.query();
while(inc.next())
{
inc.deleteRecord();
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 04:03 AM
Can you tell me, when you run kbapproval v2 and Employee Knowlege. What is the reason behind having 2 workflows?
The conditions doesnt make sense
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 04:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 08:13 PM
Ok. Great. So this should work all fine. This should be at the beginning of the KB Approval workflow
var wf =new GlideAggregate('wf_context');
wf.addEncodedQuery('workflow_versionLIKEKB approval V2^active=false^id='+current.sys_id);
wf.addAggregate('COUNT');
wf.query();
var wcounts =0;
var deletecount = 0;
if(wf.next())
wcounts = wf.getAggregate('COUNT');
var inc= new GlideRecord('wf_context');
inc.addEncodedQuery('workflow_versionLIKEKB approval V2^active=false^id='+current.sys_id);
inc.orderBy('sys_created_on');
inc.query();
while(inc.next())
{
deletecount = deletecount++;
if (deletecount<wcounts)
inc.deleteRecord();
}
GlideRecord('wf_context');
inc.addEncodedQuery('workflow_versionLIKEEmployee Knowledge^id='+current.sys_id);
inc.orderBy('sys_created_on');
inc.query();
while(inc.next())
{
inc.deleteRecord();
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 02:19 PM
Hi Sanjiv,
it was in emergency situation , Really thank you for it.
it is working fine, Thank you so much SANJIV..!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 02:28 PM
i request you , if i have any kind of issue in this thread , can i reach out you ??
i request your help here please..