New answers tagged

2

To get the value of a field dynamically you should do something like this: parameter_value = temp.get(parameterList.get(i)); which would look like parameter_value = temp.get('field1'); This is assuming temp is an object which you queried previously. You will likely have to cast these values to make them consistent for the map. Like: String parameter_value =...


4

Just iterate through the collection, assign accounts to the list and update it. List<Account> accountsToUpdate = new List<Account>(); List<AggregateResult> accsWithOpps = [SELECT AccountId, COUNT(Id)SumOfOpps, SUM(Amount)SumOfAmount FROM Opportunity WHERE AccountId IN :accIds GROUP BY AccountId]; for (AggregateResult ar : accsWithOpps) { ...


2

You're almost there. However, I would retrieve accounts to Map: Map<Id, Account> accs = new Map<Id, Account>([SELECT Id, Total_Opportunities__c, Total_Sum_Opportunities__c FROM Account WHERE Id IN :accIds]); Then you should iterate through your AggregateResult list, get retrieved values by set labels (1st example in this documentation) and set ...


1

Null values aren't serialized, because they are null. If you absolutely need the values, you'll have to serialize the data into a JSON string, return it to the client, then parse it on the client side. Here's a demonstration the problem and solution: import { LightningElement, wire } from 'lwc'; import getMapValues from '@salesforce/apex/Q349771.getMapValues'...


0

Map<String, Object> objectsByKey = (Map<String, Object>) System.JSON.deserializeUntyped( res.getBody() ); Map<String, Object> orderByKey = (Map<String, Object>) objectsByKey.get('order'); // Extract the node you want to add fields from the main object orderByKey.put('storeName', 'Sears'); // Add values objectsByKey....


2

It can get complicated if you want to add something deeper down than the top level, because you end up having to do some casting into other collections. For example, to add an order item, you have to do something like: Map<String, Object> orderDetailJson = (Map<String, Object>) System.JSON.deserializeUntyped(res.getBody()); Map<String, Object&...


0

You have to add 2 conditions in IF ie Check if the key exists in the map AND If the value corresponding to the key id 'NO' if(newmap.containskey(pbdObj.product__c) && newmap.get(pbdObj.product__c) == 'No')


Top 50 recent answers are included