function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gage Staruch 9Gage Staruch 9 

Concatenate opportunity products and roll them into a field

Hi everyone!

I am trying to build a trigger that automatically updates a field on the opportunity with a list of all the opportunity products. This is what I have so far, but it doesn't seem to be working :/ 
 
trigger OpportunityProducts on Opportunity (after update, after insert, before update) {
    for (Opportunity O: Trigger.new)
    {
        List<Opportunity> opps = new list<Opportunity>([Select Id, (Select Id, name From OpportunityLineItems) From Opportunity]);
        If (O.Name != null ) 
        String OppString = String.join(opps, '');{
        String OppString = O.Products_Listed__c;{
    }	
}
    }
}



Any help is appreciated!
AbhishekAbhishek (Salesforce Developers) 
Hi Gage,

Try the code as mentioned in the below blog,

https://developer.salesforce.com/forums/?id=906F0000000MHJcIAO

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.