I want to email picking ticket from sales order us...
# ask-stanley-ai
k
I want to email picking ticket from sales order using suitescript
c
AI generated answer (using internal Slack threads):
To email a picking ticket from a sales order using SuiteScript, you can follow these steps: 1. First, you need to generate the picking ticket URL. When you click on 'Print Picking Ticket' on a Sales Order, you will notice the URL is something like this:
<https://system.na2.netsuite.com/app/accounting/print/hotprint.nl?regular=T&sethotprinter=T&template=133&id=4539167&label=Picking+Ticket&printtype=pickingticket&trantype=salesord>
. You can use this URL structure to generate the picking ticket URL in your script. 2. Next, you need to send an email with the picking ticket URL. You can use the
N/email
module in SuiteScript to send emails. Here is a sample code snippet:
Copy code
javascript
var email = require('N/email');
email.send({
    author: authorId,
    recipients: recipientId,
    subject: 'Picking Ticket',
    body: 'Here is the picking ticket URL: ' + pickingTicketUrl
});
3. If you want to send the picking ticket as a PDF attachment, you can use the
N/render
module to render the picking ticket as a PDF, and then attach it to the email. Here is a sample code snippet:
Copy code
javascript
var render = require('N/render');
var file = require('N/file');
var email = require('N/email');

// Render the picking ticket as a PDF
var pdf = render.transaction({
    entityId: salesOrderId,
    printMode: render.PrintMode.PDF,
    inCustLocale: true
});

// Save the PDF to the file cabinet
var pdfFile = file.create({
    name: 'Picking Ticket.pdf',
    fileType: file.Type.PDF,
    contents: pdf.getContents()
});
pdfFile.folder = folderId;
pdfFile.save();

// Send an email with the PDF attachment
email.send({
    author: authorId,
    recipients: recipientId,
    subject: 'Picking Ticket',
    body: 'Here is the picking ticket:',
    attachments: [pdfFile]
});
Please replace
authorId
,
recipientId
,
pickingTicketUrl
,
salesOrderId
, and
folderId
with your actual values. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849060118
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848754942
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844848752
Please provide your feedback on this answer.