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
rushirushi 

opportunityLineItem

Hello,

 I have to create one trigger on opportunityLineItem
I can't see opportunityLineItem  in setup/customize
how can I create trigger??????

i can't see pricebook entries tab also
how can i create record for pricebook entries

 
Best Answer chosen by rushi
Anupam RastogiAnupam Rastogi
Hi Rushi,

If you need to add new fields to Opportunity Line Items then Opportunity Product is the place. Basically Opportunity Product is same as Opportunity Line Item. It's just that in Salesforce the object name that is to be used in triggers etc for Opportunity Line Items is OpportunityLineItem and the UI name is Opportunity Products.

So to add new fields to line items for to Customize -> Opportunities -> Opportunity Products -> Fields.
And to add a new trigger to Opportunity Line Items you can also go to Customize -> Opportunities -> Opportunity Products -> Triggers, other then the two ways which I shared with you earlier.

Thanks
AR

If this solves your problem then please mark it as best answer.

All Answers

Anupam RastogiAnupam Rastogi
Hi Rushi,

OpportunityLineItem has no existance of its own. It is child of Opportunity. Therefore it is not present in Customize. But you can write a trigger based on it with object name as 'OpportunityLineItem'.

And for Price Book, the tab is available in 'All Tabs'. Just make sure that you have access to this object based on your profile. You need to click the '+' sign after whatever tabs you currently have. This will take you to the view that shows all the available tabs. From there you can navigate to Price Books.

The object name of Price Book is 'Pricebook2' if you need to use it in Apex for creating a new record. Here is the screen shot showing the Price Books tab. See the red boxes.
User-added image

Thanks
AR

If you found the reply useful that solved your problem then please mark it as best answer.
rushirushi
[Error] Error: Compile Error: Incorrect SObject type: OpportunityLineItem should be Opportunity at line 1 column 1

when I try to create trigger of OpportunityLineItem , I got this error

I am following this path  to create this trigger
setup/customize/Opportunity/triggers/new
is it the correct way?


Thanks in advance.....
 
Anupam RastogiAnupam Rastogi
Hi Rushi,

The place from where you are trying to create a trigger will error this way because it is expecting a trigger based on Opportunity object over there. So to achieve what you are trying to do, you need to go through the path: Set Up -> Build -> Develop -> Apex Triggers. And then create the new trigger based on OpportunityLineItem object.

You can also create this trigger within the Developer Console if you are familiar with it. To open the console you need to go to: You Name -> Developer Console.

By any of these ways you can create this trigger.

I hope this should solve your problem.

Thanks
AR

If this solves your problem then please mark it as best answer.
rushirushi
rushi
yes, I created a trigger
but I  have to add custom fields to opportunitylineitem 
 if so it is not present in the customize
how can I create custom fields to it??????

and what is the diffrence between opportunitylineitem  and opportunityProduct
Anupam RastogiAnupam Rastogi
Hi Rushi,

If you need to add new fields to Opportunity Line Items then Opportunity Product is the place. Basically Opportunity Product is same as Opportunity Line Item. It's just that in Salesforce the object name that is to be used in triggers etc for Opportunity Line Items is OpportunityLineItem and the UI name is Opportunity Products.

So to add new fields to line items for to Customize -> Opportunities -> Opportunity Products -> Fields.
And to add a new trigger to Opportunity Line Items you can also go to Customize -> Opportunities -> Opportunity Products -> Triggers, other then the two ways which I shared with you earlier.

Thanks
AR

If this solves your problem then please mark it as best answer.
This was selected as the best answer