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
HaralambyHaralamby 

Apex Trigger help!

Hello,

 

I want to create a simple trigger which automatically inserts products after an opportunity is first created.

 

I have gotten as far as:

 

 

trigger ProductAddTrigger on Opportunity (after insert) {

}

 

What is the syntax to add opportunity products? 

Best Answer chosen by Admin (Salesforce Developers) 
aalbertaalbert

You need to insert OpportunityLineItem sObjects. Here is a link to the API docs which details each standard object.

 

You can also use the Schema Explorer that comes with the Force.com IDE to see all the fields on a given sObject. 

 

 

All Answers

aalbertaalbert

You need to insert OpportunityLineItem sObjects. Here is a link to the API docs which details each standard object.

 

You can also use the Schema Explorer that comes with the Force.com IDE to see all the fields on a given sObject. 

 

 

This was selected as the best answer
HaralambyHaralamby
Thanks!!!