via script Tool , how to lookup for the data in the attachement of the KB

Sundeep Kumar1
Tera Contributor

Bellow is the script tool which i wrote and it works perfectly fine to extract the information from a kb article, however  sometime i am not able to get the requested information from the KB article which has an attachment ( PDF, word, csv, excel):

can someone please assist, how to extract information from kb article  which has an attachment ( PDF, word, csv, excel).

 

Script inputs 

Input name

 

Description

number

Knowledge article number

 

Script:
(function(inputs) {

    // only string inputs are allowed

    // return outputs object where the keys in it are understandable by LLM

    // Retrieve KB article

    var kb_gr = new GlideRecord('kb_knowledge');

    kb_gr.addQuery('number', inputs.number);

    kb_gr.orderByDesc('version');

    kb_gr.setLimit(1);

    kb_gr.query();

 

    if (kb_gr.next()) {

        return kb_gr.text.toString();

    } else {

        throw new Error('No KB found with number ' + inputs.number);

    }

 

})(inputs);

5 REPLIES 5

Mark Manders
Giga Patron

You forgot to add the script you are using. That would be very helpful in assisting you with your question.

 

A few things you could check: are those articles just an attachment that downloads/opens on click of the KB? Is it not doing anything when there is an attachment, or is it getting the info from the article but just not from the attachment?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hey Mark, I have updated the script in the original message. Please have a look..
as I mentioned, it is working as expected to fetch the KB information.. only the problem is with extracting the information from the attachments.
also, as it is being accessed by AI agent ( no download)

Tanushree Maiti
Kilo Patron

Hi @Sundeep Kumar1 

 

Share your code. and also for KB with attachment - are you getting any error.

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hey Tanu, I have updated the original post with the script. please have a look.