# Scripted field from scripted field

**URL:** <https://discuss.elastic.co/t/scripted-field-from-scripted-field/81774>\
**Category:** Kibana\
**Created:** [April 10, 2017, 8:40am UTC](https://discuss.elastic.co/t/scripted-field-from-scripted-field/81774 "2017-04-10T08:40:59Z")\
**Posts on this page:** 3\
**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 10, 2017, 8:40am UTC](https://discuss.elastic.co/t/scripted-field-from-scripted-field/81774/1 "2017-04-10T08:40:59Z")

</div>

I want to extract the current week of the year via scripted field:  
"(new Date()).getTime()" - then format as data with WW

Now i want to use the newly created field as input for another scripted field.  
Looks like this is not allowed.

I have tried with more minimalistic scripted fields, such as: "5" 🙂  
No way. Any clue?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [April 10, 2017, 3:49pm UTC](https://discuss.elastic.co/t/scripted-field-from-scripted-field/81774/2 "2017-04-10T15:49:40Z")

</div>

As far as I know referencing another scripted field inside a scripted field will most likely fail due to the face there is no priority in computing the scripted fields so you don't always have the field present when trying to compute the other one.  
I would consider moving both calculations inside one single scripted field and do it from there.  
You can get some examples and best practices over here (even examples on using Java native types):

> **[Using Painless in Kibana scripted fields
	  	 | Elastic](https://www.elastic.co/blog/using-painless-kibana-scripted-fields)**
>
> Kibana provides powerful ways to search and visualize data stored in Elasticsearch. For the purpose of visualizations, Kibana looks for fields defined in Elasticsearch mappings and presents them as op...

---

<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 8, 2017, 3:50pm UTC](https://discuss.elastic.co/t/scripted-field-from-scripted-field/81774/3 "2017-05-08T15:50:12Z")

</div>

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