when sending email through email.send how to attac...
# ask-stanley-ai
r
when sending email through email.send how to attach that email to transactions. and how to attach it to multiple transactions at once.
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** When sending an email through
email.send
, you can attach it to a transaction by setting the transaction as the related record transaction ID. However, you can only do this for one transaction per email. The system does not support attaching an email to multiple transactions in one call. Here is a sample code snippet:
Copy code
javascript
var emailObj = email.create({
    body: 'Hello, World!',
    subject: 'Test Email',
    to: '<mailto:test@example.com|test@example.com>',
    relatedRecords: {
        transactionId: transactionId // replace with your transaction ID
    }
});
emailObj.send();
As for attaching multiple transaction IDs on
email.send
for related records, it is not possible. The relatedRecords object in the
email.send
method expects a single transaction record. Also, there is no direct way to link transaction attachments to emails. You would need to download them from the transaction's Files tab and attach them again manually. Alternatively, you could use a workflow or script to automatically copy important attachments to a standard File Cabinet folder, which would make them easier to find while composing an email.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.880249083
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851013243
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84954834
Please provide your feedback on this answer.
a
can you share complete scenario plz
r
in suitescript using emal.send like this
Copy code
email.send({
                author: 1213,
                recipients: [a@gmail.com, b@gmail.com]
                subject: emailSubject,
                body: emailBody,
                attachments: [attachment1],
                relatedRecords: {
                    transactionId: 99999,
                    entityId: entityId
                }
            })
Instead of attaching that email to just 99999, we also want it to attach it to 99998. So both the transactions, 99998 and 99999 have that email attached in their communication tab.