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
lodoss118lodoss118 

how do u access the opp linitem product field?

i tried product2Id, productId but i still can;t access it, it says it is a invalid field i.e.


item1.ProductId = '12312312313312';
item1.product2 = '123213213213';
item.product2Id = '123123123';


none of these work?????
TehNrdTehNrd
Should be last one. Can you provide a little more detail about your code and where "item" is coming from.


Message Edited by TehNrd on 04-24-2008 08:46 AM
TehNrdTehNrd
Ignore the post above that is wrong. You need to actually reference the pricebook entry to get the product2id. Give some more info and I may be able to help. This is what you will probably need to do:

Code:
Set<Id> pbeIds = new Set<Id>(); 

for(OpportunityLineItem oli : Trigger.new){
     pbeIds.add(oli.pricebookentryid);
}

Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>([select product2.Id from pricebookentry where id in :pbeIds]);

for (OpportunityLineItem oli : Trigger.new){
ID product2ID = entries.get(oli.pricebookEntryId).product2.Id;
}

 

lodoss118lodoss118
ahh because i was using my sandbox and it wasn't refreshed with the live database properly. ProductId is on the live but not on the sandbox
TehNrdTehNrd
Really? I can't refer to product2Id on an OpportunityLineItem but if it works for you thats good.


Message Edited by TehNrd on 04-24-2008 09:06 AM
lodoss118lodoss118
while i still got u here, is there anyway i can get the result of a submit for approval workflow happening currently i.e
if someone manually goes and submit for apporval is there any way say in coding i can get that result?
TehNrdTehNrd
I have looked for this my self and I do not believe the Approval History object is available to Apex Code.

There is an object called Approval but this is only for the Contracts object.
Ron HessRon Hess
Approval history is known as "ProcessSteps" , a child object (related list) of any object that you have added approvals to.
TehNrdTehNrd
Thanks Ron!

Just FYI, the table in the Schema explorer is called ProcessInstanceHistory but the SOQL queries ProcessSteps.



lodoss118lodoss118
so for example how would i get the last 3 approvals from a case?