URL scripted field w/ multiple URL link

Hi there!

I have a field that sometimes returns multiple comma separated values. .i.e.

a,b,c

I would like to create a scripted URL field that maps the values to the products on my website and show, following the above example, 3 different URLs

https://mywebsite.com/#/products/a
https://mywebsite.com/#/products/b
https://mywebsite.com/#/products/c

Would a scripted field have the ability to present multiple URLs? if so, what would be the best way to do that? The logic I have for a one value field is really simple, see below, though not sure how I would accommodate for multiple URLS

if (doc['product.keyword'].value == "N/A") {
    return ""; 
} else { doc['product.keyword'].value
}

TIA!

Azulgrana

I'm not exactly sure if this is what you're looking for, but you could use a for loop to look through all of the values if there is more than one, and concatenate each URL you generate to a string with a newline character, then at the end of the loop return the string.

That would result in one value with multiple URLs, but it wouldn't be an array type. If you wanted to emit an array you could also loop and build an array of URLs. This discuss post asked about something similar.

Thanks @devon.thomson for your answer. I'll take a look at the link you sent.

Azulgrana

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.