# Scripted Field - Change from 6.7 to 7.3?

**URL:** <https://discuss.elastic.co/t/scripted-field-change-from-6-7-to-7-3/197734>\
**Category:** Kibana\
**Created:** [September 2, 2019, 7:28pm UTC](https://discuss.elastic.co/t/scripted-field-change-from-6-7-to-7-3/197734 "2019-09-02T19:28:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JWR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jwr/32/27216_2.png) [@JWR](https://discuss.elastic.co/u/JWR)\
**Post date:** [September 2, 2019, 7:28pm UTC](https://discuss.elastic.co/t/scripted-field-change-from-6-7-to-7-3/197734/1 "2019-09-02T19:28:58Z")

</div>

I recently moved from 6.7 to 7.3 and my few scripted fields no longer seem to work. If present, I see shard errors and no records, if removed, the records appear fine (less the calculated value I want, of course). Here's one that's as basic as can be:

doc['amount'].value - doc['billed20'].value

From the source document, the amount field is always populated, but billed20 is sparse, with either a number or blank. Since my move to 7.3, do I need to account for sparse data? Did 6.7 assume blank means 0, where 7.3 doesn't?

---

<div class="post-metadata">

**Author:** ![JWR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jwr/32/27216_2.png) [@JWR](https://discuss.elastic.co/u/JWR)\
**Post date:** [September 3, 2019, 7:41pm UTC](https://discuss.elastic.co/t/scripted-field-change-from-6-7-to-7-3/197734/2 "2019-09-03T19:41:43Z")

</div>

Engineer helped... this fixes it:

if(doc['billed20'].empty){  
return doc['amount'].value  
}else{  
return doc['amount'].value - doc['billed20'].value  
}

---

<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:** [October 1, 2019, 7:41pm UTC](https://discuss.elastic.co/t/scripted-field-change-from-6-7-to-7-3/197734/3 "2019-10-01T19:41:45Z")

</div>

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