You need to sign in to do that
Don't have an account?
V100
Trying to get CreatedBy Name from Attachments
I am trying to use visualforce to show Note and Attachments as separate lists have the code below as the controller:
This works, however it returns the CreatedByID (00520000001U7ZIAA0) only and not the name.
public List<Attachment> getAtt() {
return [SELECT ID, Name, Description, Body, CreatedByID, CreatedDate FROM Attachment WHERE ParentID = :FeedbackID ORDER BY CreatedDate DESC ] ]
}
I then tried to do a mp but i'm missing a step or logic somewhere to get the name of the user
public List<Attachment> getAtt() { List <Attachment> a = [SELECT ID, Name, Description, Body, CreatedByID, CreatedDate FROM Attachment WHERE ParentID = :FeedbackID]; SET<String> cList = new Set<String>(); for (Attachment ac: a) { cList.add(ac.CreatedByID); } List <User> u = [SELECT ID, Name FROM User WHERE ID in :cList ]; Map<String, String> CreatedByMap = new Map<String, String>(); for (User cb :u) { CreatedByMap.put(cb.Id,cb.Name);//populate map } return [SELECT ID, Name, Description, Body, CreatedByID, CreatedDate FROM Attachment WHERE ParentID = :FeedbackID ORDER BY CreatedDate DESC AND CreatedByID in :CreatedByMap ]; }
This gives an error: Error: Compile Error: IN operator must be used with an iterable expression at line 50 column 141 which is
in :CreatedByMap ];
At the limit of my knowledge here so any help much appreciated.
You're trying awfully hard to do something pretty simple. How about this:
All Answers
You're trying awfully hard to do something pretty simple. How about this:
Had to take a little while cursing, swaering, hitting my head off walls, etc before rpelying!
Thanks you for your VERY simple solution, just couldn't see the obvious.