how to add option to attach pdf to cases in commun...
# ask-stanley-ai
h
how to add option to attach pdf to cases in communication?
c
AI generated answer (using internal Slack threads):
To add an option to attach a PDF to cases in the communication tab, you can follow these steps: 1. First, you need to create a PDF file. This can be done using SuiteScript's
file.create
method. You can specify the file type as 'PDF' and provide the content for the PDF. 2. Once the PDF file is created, you can attach it to a specific record (in this case, a case record) using the
record.attach
method. You need to specify the
record.Type.CASE
as the record type, provide the ID of the case record, and the file you want to attach. 3. If you want to send this PDF as an attachment in an email, you can use the
email.send
method. You need to load the file using its ID and then pass it as an attachment in the
email.send
method. Here is a sample code snippet:
Copy code
javascript
var fileObj = file.create({
    name: 'myFile.pdf',
    fileType: file.Type.PDF,
    content: 'This is the content of my PDF file',
});

var caseId = '123'; // replace with your case ID

record.attach({
    record: {
        type: record.Type.CASE,
        id: caseId
    },
    file: fileObj
});

var myFile = file.load({
    id: 'myFile.pdf' // replace with your file ID
});

email.send({
    author: authorId,
    recipients: recipientId,
    subject: 'My Subject',
    body: 'My Body',
    attachments: [myFile],
    isInternalOnly: true
});
Please replace 'myFile.pdf', '123', 'authorId', 'recipientId', 'My Subject', and 'My Body' with your actual file name, case ID, author ID, recipient ID, email subject, and email body respectively. ****** 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.822150171
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815136194
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815064549
Please provide your feedback on this answer.