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
venkatasubhashkvenkatasubhashk 

How to Get all opportunity Names in to a single field

I have written a SOQL Query to gell all Oppotunity names of some Criteria,I need to put all Opp names in a single Field of type text.Is there a Way to do it ,please Help!

bob_buzzardbob_buzzard

You can simply concatenate all of the opportunity names that you have retrieved via SOQL, but I doubt you'll be able to fit all of this into a text field - a 32k long text area gives you a better chance, but you'll still fill that up if your volume of opportunity records is large.

regger118regger118

Create an attachment out of the value i.e.

 

String oppNames = '';

for(Opportunity a :oppList){

   oppNames += a.Name + '\n';

}

 

Attachment a = new Attachment();

a.Body = Blob.valueOf(oppNames);

a.contentType = 'text/plain';

a.parentId = <IDOFOBJECT>;

insert a;