You need to sign in to do that
Don't have an account?
Nicholas Willard
Illegal assignment from LIST<Account> to String
I'm getting an error "Illegal assignment from LIST<Account> to String" when I go to execute my code in the Execute Anonymous Window. Any help would be greatly appreciated.
Here is what my code looks like so far:
public with sharing class TopDown {
public void SortAccounts(){
List<String>relAccounts = new List<String>(); //Empty list of accounts of a given Relationship Manager
String relManName = 'J%';
//Loop through all the accounts for a specified Relationship Manager
for (Account acct:[SELECT Account__c FROM Relationship_Manager_Accounts__c WHERE Relationship_Manager_Contact__r.name like :relManName]){
//Get the child id for the given account id
String childId = [SELECT id FROM Account WHERE parent.id =:acct.id];
//While there still is a child
while(childId != null){
childId = [SELECT id FROM Account WHERE parent.id = :childId];
relAccounts.add(childId);
}
}
}
}
Here is what my code looks like so far:
public with sharing class TopDown {
public void SortAccounts(){
List<String>relAccounts = new List<String>(); //Empty list of accounts of a given Relationship Manager
String relManName = 'J%';
//Loop through all the accounts for a specified Relationship Manager
for (Account acct:[SELECT Account__c FROM Relationship_Manager_Accounts__c WHERE Relationship_Manager_Contact__r.name like :relManName]){
//Get the child id for the given account id
String childId = [SELECT id FROM Account WHERE parent.id =:acct.id];
//While there still is a child
while(childId != null){
childId = [SELECT id FROM Account WHERE parent.id = :childId];
relAccounts.add(childId);
}
}
}
}
This returns a list of Accounts, which cannot be assigned to a string.