how to republish the retried KB artciles

utkarsh6
Giga Contributor

Hi All,

This is regarding the knowledge articles that I want to republish the retried articles.

I have tried the way suggested on community that I have a created a UI action named as publish that is only for articles that are retried using below script & logic. But it is not working, a UI button has sucessfully come on KB form but everything is greyedout even though I have impersonated with the assigned to user. But it is still greyed out. I am unable to edit the Valid to field on KB form.

when I am clicking on Publish button that I have created on the form for retrired articles not working as expected.

Please refer below script & UI action and also please suggest a another way or make my corrections in this .

Method->

Create a UI action with condition current.workflow_state=='retired', which will show the UI Action only on retired knowledge articles.

Set up the UI action as follows:
Table: kb_knowledge
Active: true
Show Insert: true
Show update: true
Form button: true

Condition: current.workflow_state=='retired' 

Script->

if(current.valid_to <= gs.nowDateTime()){

gs.addInfoMessage('Invalid date.Please enter future date');

current.setAbortAction(true);

}

else

 {

current.workflow_state = 'published';

current.update();

}

action.setRedirectURL(current);

 

Thanks/Utkarsh

1 ACCEPTED SOLUTION

Hi Utkarsh,

 

It was missed. Try below.

var kbis=new GlideRecord('kb_knowledge');
kbis.addEncodedQuery('workflow_state=retired');
kbis.query();
while(kbis.next())
{
kbis.valid_to='28-06-2020';
kbis.update();
}

This sets the date in future to retired articles then you can use Republish option as suggested above.

View solution in original post

15 REPLIES 15

Yes when will republish the article than the assignment group member can edit the date but till that time articles got back to its previous stage i.e retired. I checked this by impersonating those members. Yeah I am doing it as a Admin for me valid to field is not editable even the article is published. When I double click the valid to date from list view it gives me the security constraint error. But the question here is that how can I give the future date to bulk retired articles when there status is retired. If it is possible I can change there dates to future date ,than I'll repulish then &than my issue will get resolved. Thanks/Utkarsh

Hi Jaspal,

Any update on this.

 

Thanks/Utkarsh

Hi Utkarsh,

 

It was missed. Try below.

var kbis=new GlideRecord('kb_knowledge');
kbis.addEncodedQuery('workflow_state=retired');
kbis.query();
while(kbis.next())
{
kbis.valid_to='28-06-2020';
kbis.update();
}

This sets the date in future to retired articles then you can use Republish option as suggested above.

Hi Jaspal,

Thanks for providing this solution.

Can you please look into this new requirement:

https://community.servicenow.com/community?id=community_question&sys_id=9e22efe6db311c10afc902d5ca96...

Chander Bhusha1
Tera Guru

Hi Utkarsh,

You can write a fix script or background script to update the knowledge article to republish

The below script will served the purpose.

 

var kb = new GlideRecord('kb_knowledge');
kb.addQuery('workflow_state','retired');//Checking retired articles
kb.query();
whiled(kb.next())
{

//If valid to is not less than current date
if(!kb.valid_to <= gs.nowDateTime()){

kb.workflow_state = 'published';

kb.update();

}


}

 

Mark helpful and correct if it helps.

Thanks

CB