# Kibana Scripted Fields - Using one Value for a URL and another for the Label

**URL:** <https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [December 6, 2019, 6:24pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925 "2019-12-06T18:24:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seth.yes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seth.yes/32/11788_2.png) [@seth.yes](https://discuss.elastic.co/u/seth.yes)\
**Post date:** [December 6, 2019, 6:24pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925/1 "2019-12-06T18:24:42Z")

</div>

I'm trying to use scripted fields on my index pattern in Kibana 6.7. I basically want to have 'field\_A' referenced in the URL template, and 'field\_B' referenced in the Label Template, but I must be doing something wrong because I can't get it to work.

Is this possible, and if so, how do I need to format the script?

I've read the docs and they don't really cover this, but I found [another forum post](https://discuss.elastic.co/t/can-i-get-a-field-data-to-create-clickable-link-on-another-field/88463) that made it sound like it's possible..

URL Template: `https://my_domain.com/{{url_val}}`

Label Template: `{{label_val}}`

And my script:

```auto
def url_val = doc['field_A.keyword'].value;
def label_val = doc['field_B.keyword'].value; 

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/a/daa67c6310032c9463db12bd877665ccc6391794.png)

---

<div class="post-metadata">

**Author:** ![seth.yes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seth.yes/32/11788_2.png) [@seth.yes](https://discuss.elastic.co/u/seth.yes)\
**Post date:** [December 17, 2019, 9:59pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925/2 "2019-12-17T21:59:13Z")

</div>

Does anyone know if what I'm trying to accomplish is possible? I've read the painless documentation and none of it seems to cover what I consider to be a somewhat trivial use-case..

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [December 17, 2019, 11:43pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925/3 "2019-12-17T23:43:23Z")

</div>

Hi @seth.yes, unfortunately scripted fields and field formatters don't work in the way you're trying to use them. Your script can only return a single value. Since your script doesn't have an explicit return value I'm guessing it returns the value of the last line. In the `URL template` and `Label template` you can reference that single value with `{{value}}`. The word `value` is just a convention, it does not match the variable names you use in your script. The script is actually executed in Elasticsearch, whereas the URL formatter is executed in your browser, so the two know nothing about one another. The URL formatter is not limited to scripted fields, it can be used with regular fields as well.

---

<div class="post-metadata">

**Author:** ![seth.yes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seth.yes/32/11788_2.png) [@seth.yes](https://discuss.elastic.co/u/seth.yes)\
**Post date:** [December 19, 2019, 10:16pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925/4 "2019-12-19T22:16:16Z")

</div>

Thanks for the update.

---

<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:** [January 16, 2020, 10:16pm UTC](https://discuss.elastic.co/t/kibana-scripted-fields-using-one-value-for-a-url-and-another-for-the-label/210925/5 "2020-01-16T22:16:23Z")

</div>

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