function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Simran SuriSimran Suri 

Create a new task and attachment through apex

Hi,

I have a requirement where I have a custom 'Email Quote' button on Quote object, which navigates to a new visualforce page where the related Quote, Case and Opportunity attachments are fetched and attached with the email template to be sent. After the email is sent, I have to save the sent email in the Quote's Activity History section and create a new task with some predefined values and the quote attachments should be attached in the Task's Attachment section automatically. I am able to create a task successfully, but, how do I add the quote attachments to the task Attachment section programmatically? Please help !
Pankaj MehraPankaj Mehra
Hi Simran,

Create a trigger on Task object (After trigger) where you can query the Quote's attachment clone them and attach them to Task object.

Thanks