2

I am having a list of contact names in an array of String. I am trying to insert those names into a Text area field while inserting the record, but getting an error. How can I implement this?

Is there any other way I can save those names in any different field type?

3

You would need to use a string join. For instance if you want the values to be new line delimited, you would do:

someRecord.TextAreaField__c = String.join(names, '\n');

You can of course change the delimiter to any character you wish.

| improve this answer | |
  • So I have this: String[] myList = new String[]{}; .....SomeCode.....myList.add(c.Name); .....SomeCode......someRecord.TextAreaField__c = myList.join('\n');......... I am getting an error: Method does not exist or incorrect signature: void join(String) from the type List<String> What's wrong I did? I appreciate your time and efforts. – Austin Evans Dec 28 '17 at 21:29
  • 1
    @Austin Fixed the syntax in my post. – Adrian Larson Dec 28 '17 at 21:32
  • You are the rockstar at the SFSE. – Austin Evans Dec 28 '17 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.