# URL scripted field w/ multiple URL link

**URL:** <https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [November 14, 2022, 11:54pm UTC](https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910 "2022-11-14T23:54:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![azulgrana](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@azulgrana](https://discuss.elastic.co/u/azulgrana)\
**Post date:** [November 14, 2022, 11:54pm UTC](https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910/1 "2022-11-14T23:54:13Z")

</div>

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

```auto
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

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

```

TIA!

Azulgrana

---

<div class="post-metadata">

**Author:** ![devon.thomson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devon.thomson/32/85468_2.png) [@devon.thomson](https://discuss.elastic.co/u/devon.thomson)\
**Post date:** [November 15, 2022, 9:06pm UTC](https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910/2 "2022-11-15T21:06:32Z")

</div>

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](https://discuss.elastic.co/t/kibana-painless-scripted-fields-loop-on-array-of-objects/132847/5) asked about something similar.

---

<div class="post-metadata">

**Author:** ![azulgrana](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@azulgrana](https://discuss.elastic.co/u/azulgrana)\
**Post date:** [November 15, 2022, 9:42pm UTC](https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910/3 "2022-11-15T21:42:42Z")

</div>

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

Azulgrana

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2022, 9:42pm UTC](https://discuss.elastic.co/t/url-scripted-field-w-multiple-url-link/318910/4 "2022-12-13T21:42:45Z")

</div>

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