I want to get id of product selected on opportunity record. There is lookup relationship between Opportunity and product. All I want is id of the product selected by user on that record. below is my code.
public without sharing class Test {
public static void Org (List<Opportunity> organisations){
Set<Id> OrgIds = new Set<Id>();
for(Opportunity o : organisations){
OrgIds.add(o.Id);
}
for( Product__c product : [SELECT ID, Name, Product_ID__c FROM Product__c WHERE ID IN :OrgIds])
{
system.debug('I am in here' + product.ID );
}
}
}
Product__C is a Custom object
Added lookup between opportunity and product object.