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?

1 Answer 1

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.

3
  • 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. Commented Dec 28, 2017 at 21:29
  • 1
    @Austin Fixed the syntax in my post.
    – Adrian Larson
    Commented Dec 28, 2017 at 21:32
  • You are the rockstar at the SFSE. Commented Dec 28, 2017 at 21:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .