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
pearlbearpearlbear 

How to insert a new Activity Record?

I'm writing a trigger, which, upon certain conditions, should write a new activity record connected to the Opportunity. I'm fairly new to Salesforce and APEX, so this is stumping me. I can figure out how to create a new sObject, and write records salesforce, etc. but the Activities object seems weird and special, and I can't quite puzzle out how to do this. Even URLs are welcome.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

You want to create an sobject of type task, and set its whatId field to the Id of the opportunity.

All Answers

SuperfellSuperfell

You want to create an sobject of type task, and set its whatId field to the Id of the opportunity.

This was selected as the best answer
pearlbearpearlbear

That was it. Perrrfect. Thanks!