multiple choice field in transformation - split | to list

L Younkins asked on August 30, 2022 15:14

I have a news repeater that is using a transformation. I have a multiple choice field that shows the category of the news type. It works, but as it feeds onto the page, it originally was separated by a |. I was able to replace the | with a space, but it still displays the fields together. I need them to be separate. See image. I need Athletics, Featured, and Scholarships to be listed separately. In doing a search here on devnet, I found a script that split the field into a list, but it gives me an error. Here is my code: Image Text

Here is the current output: Image Text

Recent Answers


Juraj Ondrus answered on August 31, 2022 07:27

Another way would be creating a custom transformation method. Its input would be the multiple choice field value. In the method's logic you will separate the list according and the output would be your desired format.

1 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 14, 2022 09:01

Hi L Younkins,

You are getting this result because your code executed gives just one span element with a few words separated with spaces:

<span class='category'>Articles  Featured  Scholarships</span>

You need to modify the code to get the following result instead, to wrap your categories in separate spans:

<span class='category'>Articles</span><span class='category'>Featured</span><span class='category'>Scholarships</span>
0 votesVote for this answer Mark as a Correct answer

L Younkins answered on September 14, 2022 15:41

That gives an error message: '<'[TempITemplate.Template]: http://server/CMSVirtualFiles/Transformations/=vg=f3590959-0209-4d0c-b2a8-48f3ceb885e7/CMS.News/List_Landing.ascx(5): error CS1525: Invalid expression term

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.