Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Help with a script

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

@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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

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