You need to sign in to do that
Don't have an account?

Trigger to populate concatenated string
I have two custom objects.
Order and Assigned
Assigned has a lookup to order and a lookup to the user.
On the order object have a text area field I want to populate a list of assignees from the assigned object user lookup.
How do I do this?
Thanks,
Your requirement is expressed a little ambiguously (or i'm really tired). I am a little uncertain whetehr you want to populate a list of assignees with the text field value stored on the parent or populate the test field on the parent with some data extracted from a list of related assignees.
If you want to populate a child based on the parent, then define a workflow or trigger on the child to use the lookup relationship. If you want to populate the parent with details from the children, then create a trigger on the parent to query the children and iterate across them to find some value to fill in some field.
nb: If your two objects have existing instances, then you may want to run some code to find records and perform the necessary updates to have the workflow/trigger fire and place objects in desired state.
Thanks - sorry for the lack of detail. I wrote it while really tired.
Order is the parent and Assigned in the child.
They are not connected with a master-detail they are just connected via lookupfield.
On the assigned object there is a field with a look up to the user. For every assigned record I want to take the user look up name and concantenate all of the "assignees" and populate a text field on the parent object "Order".
Here is what I have but it is just returning null values at this point. I can't figure out why.
correct me if i'm wrong, but won't this overwrite the entries in the parent object for those children that are not in the currently updated set? Don't you need to iterate across the entire collection rather than just the set that are being inserted or updated at that point.
1) i meant that having the complete set of parent ids, search for all children with matching parent ids, rather than what you are using, which is a subset.
2) consider using a map based implementation. It would read more cleanly and should be fairly optimised for searching (that is, not too much additional processing expense).
3) add debug statements, examine the various states
4) i can't believe you need this functionality - usually people use a related list on the page layout or build the code that calculates the string into the VF controller that displays the object.
5) you can modify it so that if the trigger is an insert, just append the name rather than having to do a more extensive search of all children for that parent.