Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to show latest version of knowledge articles through script

Asha Pathak
Tera Contributor

I have created fixed script to publish retired articles and change valid to date increased by 30 days to see retired articles on portal , its working , only the issue is client want to publish latest version of articles

How to achieve this via script?

this is my script

 

AshaPathak_1-1710291232198.png

Please help!

 

1 REPLY 1

Harish KM
Kilo Patron
Kilo Patron

HI @Asha Pathak you can utilise OOB script include in your fix script which will check versions

script include name: GlobalKnowledgeUtilSNC

check function:canRepublish

HarishKM_1-1710291705273.png

 

 

or you could sort by date to get the latest article like below

var gr = new GlideRecord('kb_knowledge');

gr.orderByDesc('sys_updated_on');

gr.query();

while(gr.next()) {

gs.info('Knowledge Article: ' + gr.number + ', Version: ' + gr.version + ', Last Updated: ' + gr.sys_updated_on);

}

 

Regards
Harish