New answers tagged

0

It does only display Prod2 and Prod3 because first contains will never have the Prod1 in it as it gets added in the else condition. What you need is having a map with rev.profit1__c+rev.profit2__c as keys and Reverence names as values as a list. So that way you can first populate the map and then check from there. Sample code for the logic: //create ...


2

If your goal is simply to get a map collection of <ID, sorted list (with unique values)>, then instead of using multiple collections, you can write a compact code (see code snippet below) using a single map collection variable. The idea is to use contains method of List class. You may also use indexOf method. Map<Id,List<String>> oppyMap = ...


1

Well, map.values() return all the values in the map irrespective of the key. Instead, you need values from a particular key. To get values from the map, you can simply put the set of string to a new List sort it, convert it back to set of String & put it back to the map. for(Id oppId : oppyMap.keySet()){ List<String> valuesList = ...


2

By far the best way to do this is to use an aggregate query. Doing this in before update of Account will collect the number of Contacts with the Phone field set to a value: Set<Id> ids = Trigger.newMap.keySet(); List<AggregateResult> results = [ SELECT COUNT(Id) contacts, AccountId account FROM Contact WHERE AccountId IN :ids ...


1

I guess you can do something like this // added filter in inside query for phone, using set of acc ids from Trigger map List<Account> accsWithContacts = new Map<Id, Account>([ SELECT name, id, (Select name, id, Phone from Contacts WHERE Phone != NULL) FROM Account WHERE Id = :Trigger.newMap.keyset() ]); // using map to get correct record ...


0

It's the same as sending any other email from Email Studio: Choose an email and click on "Send" In the "Select Audience" section, choose "Lists and Groups" from the dropdown Choose the list that you wish to send to and drag and drop it into the "Targeted" section If you need to segment the list before sending, use ...


4

Depending on where you get/see/view the error, Salesforce can have a hard time displaying the entire message (because < and > are what xml/html use, and rendering html based on user input all willy-nilly is not a good idea). I suspect the more complete error message is Illegal assignment from List<AggregateResult> to List<Lead> When you ...


2

If they need to be in the same variable, use sObject instead: public List<sObject> allrecords { get { if(allrecords == null) allrecords = new List<sObject>(); return allrecords; } set; } If you need two separate variables, then you can just use two variables. To combine the list based on updates, use a getter ...


2

Your starting string (0011b00000sXK8mAAG, 0011b00000sXKBgAAO, 0011b00000sXKgDAAW,) contains two space characters. If you split the string on the commas, there is a preceding space character that gets included in the second ( 0011b00000sXKBgAAO) and third ( 0011b00000sXKgDAAW) elements in your list. You will see the spaces if you run the following: String t = ...


Top 50 recent answers are included