how to download knowledge base articles from servicenow through api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 12:29 AM
Hi,
I have an api which gives the KB(Knowledgebase ) articles and along with many fileds,I want to download the articles from the api. Please suggest.The below api returning text(artilce),I want to download using servicenow rest api.
API:https://dev82597.service-now.com/api/now/table/kb_knowledge?sysparm_query=short_descriptionLIKESpamand
output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 01:44 AM
Hi
unfortunately it is not really clear what your issue is.
Please provide more details and describe better what your expectation is.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 01:49 AM
Hi
https://community.servicenow.com/community?id=community_question&sys_id=7678f2efdb514110019ac2230596196a
above is my question link
1. In Knowledge Base the article validity is (ex:1825 = 5years / 2yrs) so article validity populate to Valid to date in Knowledge article to 5 yrs . i have written logic i can add more than 30 days . so(1825+30 days i can add) if i am try to add more than that it should print date in alert .user should select less than yyyy-mm-dd.
i tried printing months it is working as per below script i want print date instead of months
2. if article validity is empty by default valid to date is 2100-01-01 in these case it should print alert from current date to 1year +30= 395 days
below script is i tried for months can anyone help me for date
client script :
function onSubmit() {
//Type appropriate comment here, and begin script below
if (g_scratchpad.isFormValid){
return true;
}
var actionName = g_form.getActionName();
var ga = new GlideAjax('KnowledgeTimeDifference');
ga.addParam('sysparm_name','getDiff');
ga.addParam('sysparm_sysid',g_form.getValue('kb_knowledge_base'));
ga.addParam('sysparm_start',g_form.getValue('valid_to'));
ga.getXMLAnswer(function(answer) {
answer = JSON.parse(answer);
if(answer.status == false)
{
alert("Please select the Valid to date less than "+answer.days+" months greater than today's date");
}
else
{
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
});
return false;
}
script include:
var KnowledgeTimeDifference = Class.create();
KnowledgeTimeDifference.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDiff: function() {
var arval = '';
//var stDateVar;
var sysid = this.getParameter('sysparm_sysid');
var gr = new GlideRecord('kb_knowledge_base');
gr.addQuery('sys_id', sysid);
gr.query();
if (gr.next()) {
arval = gr.getValue('article_validity');
}
if (arval == null) {
arval = '0';
}
var gdt1 = new GlideDateTime();
gdt1.addDaysUTC(parseInt(arval) + 30);
var days = 0;
if (arval == '0') {
days = 13;//yyyy-mm-dd
} else {
days = Math.round((parseInt(arval) + 30) / 30);
}
var start = this.getParameter('sysparm_start');
var gdt2 = new GlideDateTime(start);
var dur = GlideDateTime.subtract(gdt1, gdt2);
var date = new GlideDate();
date.setValue(gdt2);
date.addMonths(days);
var dif = dur.getNumericValue();
var js = {};
if (dif <= 0) {
js.status = true;
} else {
js.days = days;
js.status = false;
}
return JSON.stringify(js);
},
type: 'KnowledgeTimeDifference'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 02:12 AM
Hi,
I want to download KB articles from servicenow through API.
Exmaple:
API:https://dev82597.service-now.com/api/now/table/kb_knowledge?sysparm_query=short_descriptionLIKESpamand.
In the below output,I have text field with description in below.the test description I want to download in wiki page fomrate.Plz suggest
output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 02:58 AM
Hi
sorry, but repeating the same question text as an answer is not really helpful.
Instead you could start by explaining what your understanding of "downloading of knowledge articles" is. Do you expect a Word file? A PDF file? Anything else?
Maik