You need to sign in to do that
Don't have an account?

Product2 SOQL Query
public static String getProjectNumber( String id ) {
List<Opportunity> values = new List<Opportunity>();
values =
// return
[SELECT Id, Name, (SELECT PricebookEntry.Product2.Serial_Number__c,
PricebookEntry.Product2.Stock_ID__c,
PricebookEntry.Product2.RecordType.Name
FROM OpportunityLineItems
where PricebookEntry.Product2.RecordType.Name = 'Service Body' )
FROM Opportunity WHERE Id = :id limit 1];
return values.PricebookEntry.Product2.Serial_Number__c;
}
Get error Variable does not exist: PricebookEntry
Here is the data:
PricebookEntry.Product2.Serial_Number__c STETEST
PricebookEntry.Product2.Stock_ID__c PricebookEntry.Product2.RecordType.Name Service Body
List<Opportunity> values = new List<Opportunity>();
values =
// return
[SELECT Id, Name, (SELECT PricebookEntry.Product2.Serial_Number__c,
PricebookEntry.Product2.Stock_ID__c,
PricebookEntry.Product2.RecordType.Name
FROM OpportunityLineItems
where PricebookEntry.Product2.RecordType.Name = 'Service Body' )
FROM Opportunity WHERE Id = :id limit 1];
return values.PricebookEntry.Product2.Serial_Number__c;
}
Get error Variable does not exist: PricebookEntry
Here is the data:
PricebookEntry.Product2.Serial_Number__c STETEST
PricebookEntry.Product2.Stock_ID__c PricebookEntry.Product2.RecordType.Name Service Body
Hi Ron,
Following are the 2 approaches to get the desired result and you can modify the code accordingly further.
To access data from "List" either use a loop or index to get the value of it.
Thanks
DG
All Answers
[SELECT Id, Name, (SELECT .Product2.Serial_Number__c,
Product2.Stock_ID__c,
Product2.RecordType.Name
FROM OpportunityLineItems
where Product2.RecordType.Name = 'Service Body' )
FROM Opportunity WHERE Id = :id limit 1];
return values.Product2.Serial_Number__c;
Thanks,
Maharajan.C
Hi Ron,
Following are the 2 approaches to get the desired result and you can modify the code accordingly further.
To access data from "List" either use a loop or index to get the value of it.
Thanks
DG