Help with a script

Community Alums
Not applicable

Hi all, 

In the virtual agent, I have a script (see below) that shows a list of all invoices (see image). 

I would like to give the ability to download those records if they need, how can I add the functionality to the below script? Thanks 

 

Current list of invoices:

 
 
 
 

VA.jpg

 

Current script:

 

(function execute(table) {
/* Write a glide record query, and return the glide record.
For example:
var gr = new GlideRecordSecure('customer_account');
gr.addQuery('contact',vaInputs.user.sys_id);
gr.query();
return gr;
*/
 
var gr1 = new GlideRecordSecure('x_customer_invoice');
var gr = new GlideRecordSecure('customer_contact');
gr.addQuery('email',vaInputs.user.email);
gr.query();
if(gr.next ())
{
gs.info('Test '+gr.account);
gr1.addQuery('account',gr.account);
gr1.query();
}
return gr1;
})(table)
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

I believe the only way is to use HTML bot response where you can show the columns you want and in 1 column have link to that record so that they can download it as pdf or excel etc

something like this you can give in the anchor tag URL

var url = '/' + gr.getTableName() + '.do?sys_id=' + grgetUniqueValue() + '&PDF';

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Community Alums
Not applicable

Hi @Ankur Bawiskar , so do you mean something like this?

I pointed the script I created, and added the new HTML response. So are you saying that by adding the code you provided, it will show  the list of the invoices downloadable?

Dev86_0-1723464488305.png