I have a requirement that I need to display all Account Team Members for a specific Account in a text field for reporting. using this post as a guide, I can a list of the results but I cannot figure out how to takes the result and convert it to a string that I can put into the field. I started working in the dev console so I can test out the syntax quickly. Example:
Set<ID> accId = new Set<Id>(); accId.add('001A000001LFBFT'); String dan =[SELECT User__r.FirstName, User__r.LastName FROM NPD_Account_Team__c WHERE Account__c IN :accId ORDER BY User__r.FirstName DESC].User__r.FirstName; System.debug('dan is:: ' + dan);
This compiles but when run it gives the error:
List has more than 1 row for assignment to SObject.
Ideally what I want to happen is that if I have Account Team members as: Tom Dick Harry
I would have a string that would say 'Dick, Harry, Tom'