Hot answers tagged

4

I think you're accidentally conflating the two approaches we can take when it comes to SOQL for loops. Have the loop variable be a single SObject instance (e.g. for(Contact cont :[query here])) Have the loop variable be a List<SObject> (e.g. for(List<Contact> contactGroup :[query here])) The single object loop variable version is generally what ...


3

Your query is missing the querying of the related record likely called Installed_Product__c. The field Installed_Product__c is just the Id of that record. To get fields from that object you will need to include _r references e.g. Installed_Product__r.Status__c in the query. If you haven't already, I suggest you work through e.g. Write SOQL Queries, focusing ...


3

you can use sobject get method, in order to get value of the sobject field dynamicaly: system.debug('----> ' + listolivia[0].get(platField));


2

Here's a method I wrote up for you. public Map<String, List<sObject>> getChildRecords(sObject record) { Map<String, List<sObject>> results = new Map<String, List<sObject>>(); // This avoids the dreaded: // SObject row was retrieved via SOQL without querying the requested field Map<String, Object> ...


2

It isn't the variable's content (one SObject) that dictates the amount of heap space but rather by how large a chunk of data that the platform loads in one go. The for loop approach is, as per the documentation you mention, ensuring that the over-all results are loaded in multiple, smaller chunks but not just one record at a time which would be highly ...


2

Every field you want to read must be in the SOQL query. The if condition checks the value of Installed_Product__r.Status__c, so that field must be added to the query in the first list of the snippet: List<Service_Contract_Products__c> coveredProducts = [SELECT Id, Installed_Product__c, Installed_Product__r.Status__c FROM Service_Contract_Products__c]; ...


1

You are passing opportunity id as :ApexPages.currentPage().getParameters().get('OpportunityId') for opportunity lines and contact roles. But it should be : ApexPages.currentPage().getParameters().get('id') public class controllerTest { public Opportunity opportunity {get; set;} public List<OpportunityLineItem> oppLineItem {get; set;} public list<...


Only top voted, non community-wiki answers of a minimum length are eligible