# Url field formatter to exploit multiple fields

**URL:** <https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598>\
**Category:** Kibana\
**Created:** [April 25, 2017, 4:59pm UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598 "2017-04-25T16:59:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michimau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michimau/32/23262_2.png) [@michimau](https://discuss.elastic.co/u/michimau)\
**Post date:** [April 25, 2017, 4:59pm UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/1 "2017-04-25T16:59:49Z")

</div>

Is it possible to have url formatted fields with label from another field?

something equivalent to html: \< a href="fieldUrl"\>fieldLabel \< /a \>

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [April 26, 2017, 6:21am UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/2 "2017-04-26T06:21:13Z")

</div>

i guess you could use a scripted field to generate something like this.

`return '<a href="' + doc['fieldUrl'].value + '">' + doc['fieldLabel'].value + '</a>';`

hope this gives you some ideas.

---

<div class="post-metadata">

**Author:** ![michimau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michimau/32/23262_2.png) [@michimau](https://discuss.elastic.co/u/michimau)\
**Post date:** [April 26, 2017, 7:04am UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/3 "2017-04-26T07:04:20Z")

</div>

brilliant, thank you 🙂

however, this does not work:  
return '\< a href="' + doc['dataUri'].value + ' " \> ' + doc['dataTitle'].value + '\< /a \>';  
while this one does:  
return '\< a href="' + params['\_source']['dataUri'] + ' "\>' + params['\_source']['dataTitle'] + '\< /a \>';

the returned string is something similar to:  
\< a href="[www.google.com](http://www.google.com)"\>link to google\< / a\>

The problem is how to use the html code to display it as clickable link, in a table visualization for instance.  
I have tried to use the Url formatter playing with "Url Template" and "Label Template" settings with no positive outcome.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [April 26, 2017, 7:47am UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/4 "2017-04-26T07:47:15Z")

</div>

i don't think this will be possible.

you could use url formatter but you won't get to exactly what you are looking for:

- edit the `dataUri` field in managenent
- set it to use URL formatter
- in the Label template enter your label (a fixed one ... something like `my link`) if you don't want the url to be visible in the table.

but, you can't use another field to set the label ...  
even if this would be scripted field which would produce something like `my label:my url` there is no way to split this in the url template/label template as {{value}} at those fields represents the whole field value.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [April 26, 2017, 7:48am UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/5 "2017-04-26T07:48:00Z")

</div>

might be worth opening a feature request on github.

---

<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:** [May 24, 2017, 7:51am UTC](https://discuss.elastic.co/t/url-field-formatter-to-exploit-multiple-fields/83598/6 "2017-05-24T07:51:20Z")

</div>

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