PDF naming using print button
Hi everyone.
I have a print button for e.g. Purchase Orders.
When I click, it downloads the current PO as a PDF. However, the name is "Purchase Orders1.pdf".
I would like the PDF to be named after the Purchase Order Number for which I have a field.
My current code:
printRecord(record('Purchase Orders',Id), "Print Form")
Code which does do the job but only saves it in the Attachment tab:
importFile(this, printAndSaveRecord(this, "Print Form"), "PO " + 'PO No.' + ".pdf")
I do not want to save the PDF to Ninox as it requires additional steps for my staff. I just want it to download with the PO number as name.
Is this a limitation of Ninox or can it be done somehow?
Thanks for any help.
1 reply
-
For anyone interested, I did find a solution. While it does require to save the PDF in Ninox, it doesn't require any additional step.
Hereis the code which works for me.
Important is you add waitForSync(); right before the SendEmail section or else the PDF won't be ready once the email is sent.
importFile(this, printAndSaveRecord(this, "Print Form"), "PO " + 'PO No.' + ".pdf");
let myPdf := printAndSaveRecord(this, "Print Form");
let myName := "PO " + 'PO No.' + ".pdf";
importFile(this, myPdf, myName);
waitForSync();
sendEmail({
from: "name@domain.com",
to: Recipients,
cc: 'Additional Recipients',
subject: "Purchase Order " + 'PO No.',
text: Message,
attachments: file(this, myName)
});
'Submitted on' := now()
Content aside
- 2 yrs agoLast active
- 1Replies
- 334Views