New answers tagged

2

Unfortunately apex doesn't handle list-level type conversion so if "obj" is a List<Object> and even if each Object is actually a String you still cannot convert that list directly to a List<String> via type casting. You have two options. First is to do a loop: List<Object> obj = ...; List<String> objAsStrings = new List<...


2

Objects are passed by reference, which means that two variables can refer to the same place in memory. You can read a much longer explanation here. As a simple example: Account a = new Account(Name='Demo'); Account b = a; b.Name = 'Demo 2'; System.debug(a.Name); // Demo 2 To fix this, you must create all new objects. For Lists, we have the deepClone method: ...


0

List<Object> myStringObjects = new List<Object>{'a', 'b', 'c'}; List<String> myStrings = String.join(myStringObjects, ';').split(';'); We can go future and create method: public List<String> convert(Object iterableObject) { return String.join(new List<Object>(iterableObject), ';').split(';'); } List<String> ...


3

acc.Contacts will return all Contacts related to the Account if you query for them first. (That is assuming that there are Contacts associated to the Account - if there are no related Contacts, then obviously any attempt to query for them or reference them will not show anything.) If you change your first line to: Account acc = [SELECT ID, NAME, (SELECT Id ...


5

Given the code you have, no, acc.Contacts will not return any Contacts. To get related Contacts, you need to query for them. Since you haven't queried for them, you get an empty list (honestly, I'm a little surprised that you didn't get an error about "SObject row was retrieved via SOQL without querying the requested field"). You can use an inner ...


0

Maps store only one value per key, so if you don't take care, you'll displace the old value. That leads to something like this: User u = allUsers.get(someUserId); if(u == null) { allUsers.put(someUserId, u = new User()); } u.Director__c = null; You can't combine multiple objects in to a single object in the map, you have to start with a map to begin with.


1

The issue is that Welcome Emails on lists are only able to use Classic Emails. The reason this is a major issue is that SFMC has sunset the classic content and Classic Emails to no longer be able to be used. This means that essentially this capability can no longer be used. Your best bet is to complain to your Account Rep and see what they can do. Other then ...


Top 50 recent answers are included