UI Action -Print to PDF

pramn
Tera Guru

Morning Team, 

 

W have a requirement to Create a UI action to PRINT To PDF, I have done something but not getting expected result .

Could you Please help me with it .

pramn_0-1696571492832.png

script is 

 function gen_pdf() {
 var rm = new sn_ws.RESTMessageV2();
rm.setHttpMethod('GET');
var url = gs.getProperty("glide.servlet.uri") + current.getTableName() + '.do?PDF&sys_id=' + current.sys_id;
rm.setEndpoint(url);
rm.setBasicAuth(gs.getProperty('glide.user.userid'), gs.getProperty('glide.user.password'));
rm.saveResponseBodyAsAttachment(current.getTableName(), current.sys_id, current.number + ".pdf");
var response = rm.execute();
action.setRedirectURL(current.getTableName()+'.do?sys_id='+current.sys_id);
 }
 
Please help me to fix this .
Thanks in advance .
10 REPLIES 10

Tai Vu
Kilo Patron
Kilo Patron

Hi @pramn 

Have you tried this trick?

var url = g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue() + '&PDF';
g_navigation.open(url);

 

Screenshot 2023-10-06 at 13.13.52.png

 

Let me know if it works for you

 

Cheers,

Tai Vu

do i need to add this code in my code ? please help me with it ..my background is not development ...so looking for the help! 

Sure there you go!

UI Action: 

print_pdf.png

 

OOTB Export

export_pdf.png

Thanks , 

Thats working for me now ...but the problem is when ever i am opening the  new record its every time its getting auto downloaded . 

Please help me to fix this