# How to attach a URL to a string in painless

**URL:** <https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [October 30, 2019, 9:49pm UTC](https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951 "2019-10-30T21:49:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hedi.guedidi](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@hedi.guedidi](https://discuss.elastic.co/u/hedi.guedidi)\
**Post date:** [October 30, 2019, 9:49pm UTC](https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951/1 "2019-10-30T21:49:38Z")

</div>

Hey everyone,  
I want to create a scripted field with painless that basically does this:

If(doc['field'].value== val){  
return("go to site 1");}  
Else{return ("go to site 2");}

And I don't see how I can add a hyperlink (an url to my "go to site 1" and" go to site 2")  
I Want different url for each case and I don't want the url to show in my dashboard just "go to site 1" and "go to site 2".  
Anyone got any idea how I can do this?

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [November 1, 2019, 6:24pm UTC](https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951/2 "2019-11-01T18:24:46Z")

</div>

You can use the scripted field to return a URL string and [string field formatter](https://www.elastic.co/guide/en/kibana/current/field-formatters-string.html) to format that URL string into an hyper link when rendered.

---

<div class="post-metadata">

**Author:** ![hedi.guedidi](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@hedi.guedidi](https://discuss.elastic.co/u/hedi.guedidi)\
**Post date:** [November 2, 2019, 10:56am UTC](https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951/3 "2019-11-02T10:56:44Z")

</div>

Thanks for your answer! That's what I was trying to do but it gives me the same label for both URLs and I want to have two different labels that don't have the URLs in them .

---

<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:** [November 30, 2019, 10:56am UTC](https://discuss.elastic.co/t/how-to-attach-a-url-to-a-string-in-painless/205951/4 "2019-11-30T10:56:53Z")

</div>

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