KB articles valid through date MASS change

markalpine
Kilo Expert

All of our KB articles are set to expire Jan. 1st 2020.

Is there a way to change ALL of them at once to a latter date?

Also how do I adjust the default valid through date?

 

Thank you for your help.

1 ACCEPTED SOLUTION

markalpine
Kilo Expert

All though these answers may work the simplest way to resolve this was for HI to install Madrid PAtch 7 which reset everything to Jan. 2100.

Thanks!

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use fix script to set the date to some other value

in left navigation type fix script and click new; give some name; use sample script provided below

Once done execute it

1) use try catch block to handle exception

2) add proper log statements to know whether the script got completed

3) use setLimit() to restrict the records which gets updated; check whether update happened properly; if yes then remove the setLimit() for further execution

4) use setWorkflow(false) to avoid triggering any business rule i.e. after/before update business rules

sample script below; I have set the valid_to -> 2021-01-01

updateRecords();

function updateRecords(){

try{

gs.info('Fix Script to update record started');

var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery("valid_toON2020-01-01@javascript:gs.dateGenerate('2020-01-01','start')@javascript:gs.dateGenerate('2020-01-01','end')");
gr.setLimit(5);
gr.query();
while(gr.next()){
gr.valid_to = '2021-01-01';
gr.setWorkflow(false);
gr.update();
}

gs.info('Fix Script to update record ended');

}
catch(ex){
gs.info('Exception is: ' + ex);
}

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

This is almost exactly what I needed. However, Optimally I'd like to have the fix script set 'Valid To date' to the 'Updated date' + 1 year. Yet to find a method to do that. ideas?

markalpine
Kilo Expert

All though these answers may work the simplest way to resolve this was for HI to install Madrid PAtch 7 which reset everything to Jan. 2100.

Thanks!

Aaron Silverman
Tera Contributor

I didn't get the answer I was hoping to see, but I did figure it out on my own. I'm documenting it here in case anyone else comes across this and doesn't want to run scripts or mess with client scripts or custom code.

Previously, we did not have Knowledge Advanced enabled, so this was an easy task to do before as a mass edit from the list view of Knowledge All. Since we enabled Knowledge Advanced and the respective versioning feature, however, the required checkout option activated some client scripts that prevent fields from being edited without checkout and read-only on the list and form views. I had to make a few changes to be able to edit articles from the list view, but it was fairly easy once I figured it out. Here are the steps I took to successfully update multiple articles' "Valid to" dates (and can be used for any Knowledge field as well):

We first need to change the default list control setting to enable list editing on all KB articles.

1. From the Filter Navigator, navigate to Knowledge > Articles > All.

2. Right-click on any header column in the list and select Configure > List Control.

3. On the kb_knowledge form, in the List edit type field, select "Save immediately (cell edit mode)" and click Update.

Now that the list is editable, we need to allow specific fields to not require checkout in order to be edited. In order to make specific fields not read-only, we need to change a Knowledge property.

4. Navigate to Knowledge > Administration > Properties.

5. Scroll down near the bottom of the page to the "Article Versioning Properties" section. Again, these are steps for Knowledge if you have the Knowledge Advanced plugin enabled. If you do not, I believe you can stop here and be able to edit the list as you see fit.

6. If the "Enable article versioning feature." option is selected, that is the option that requires KB articles to be checked out, otherwise they appear as read-only. We do not need to change this setting. This is probably the reason you have Knowledge Advanced even enabled. Instead, select the option to "Enable minor edits to the published article without creating a new version."

7. Under the last option in that section, "List of fields (comma-separated) that can be edited on published articles without creating a new version." make sure "valid_to" is listed as a field (it was already populated in my instance, but the minor edits option was not enabled by default). If you want to add additional fields to be edited without checkout, this is where those should be added as well.

8. Click Save.

ServiceNow will now allow the "Valid to" field to be edited from either the form or list view, without requiring checkout. I personally sort the Knowledge All by "Valid to" date ascending, with view blocks of 100. I also filter by workflow, since I'm only concerned with updating those articles in draft or published states. In order to not inundate the system, I also filter by date ranges, so I only update chunks of articles at a time (I found 1000 records at a time updated in less than 60 seconds). I also utilize the Update All list function by right-clicking the header column and selecting Update All. This will display a prompt letting you know how many rows will be affected by the update. Click OK. This navigates to a form where the only field I modify is the "Valid to" field. Remember that any field you modify on this form will update ALL articles that you have selected. Once you are comfortable with the change, click Update.

Hope this helps someone who is struggling with Knowledge Advanced.