# Scripted field not working on some of the strings

**URL:** <https://discuss.elastic.co/t/scripted-field-not-working-on-some-of-the-strings/212853>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [December 23, 2019, 2:17pm UTC](https://discuss.elastic.co/t/scripted-field-not-working-on-some-of-the-strings/212853 "2019-12-23T14:17:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaifali](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@Shaifali](https://discuss.elastic.co/u/Shaifali)\
**Post date:** [December 23, 2019, 2:17pm UTC](https://discuss.elastic.co/t/scripted-field-not-working-on-some-of-the-strings/212853/1 "2019-12-23T14:17:07Z")

</div>

I have created one scripted field named as "ErrorGroup" in which I have write below script :

if(doc['Message.keyword'].value!=null && doc['Level.keyword'].value=='Error'){if(doc['Message.keyword'].value.contains('Error fetching picking lists items for picklist id')){return 'Error in fetching picking lists items';} else if(doc['Message.keyword'].value.contains('WebMPL:Article not present in picklist')){return 'Article not present';}return 'other';}

using this script, Message field read as null for "Error fetching picking lists items for picklist id" string but it is working fine for ''Message'' which have "WebMPL:Article not present in picklist" value.

Full Value of these message field is 🙂

1)WebMPL:Error fetching picking lists items for picklist id : , Error: metrosystems.mcrm.common.Exceptions.SiebelException: Error fetching picking list items fro picklist ''  
at metrosystems.mcrm.data.soe.Repository.PickingRepositoryBetty.GetPickingListById(String id, String languageCode, String accountId, String custStoreId, Boolean getFromService) in d:\TeamCity\buildAgent\work\616e3af0ffbc99a9\metrosystems.mcrm.data.soe\Repository\PickingRepositoryBetty.cs:line 548  
at metrosystems.mcrm.business.soe.Service.PickingService.GetPickingListById(String id, String langCode, String pickListStore, String accountId, String custStoreId, Boolean getFromService) in d:\TeamCity\buildAgent\work\616e3af0ffbc99a9\metrosystems.mcrm.business.soe\Service\PickingService.cs:line 129  
at metrosystems.mcrm.soe.Controllers.PickingApiController.GetPickingItems(String id, String pickListStore, String accountId, String custStoreId, Boolean getFromService) in d:\TeamCity\buildAgent\work\616e3af0ffbc99a9\metrosystems.mcrm.soe\Controllers\PickingApiController.cs:line 125 ======\> Its is not working correct, for this ErrorGruop I am getting null value.

1. WebMPL:Article not present in picklist. Barcode : 3484700007946====\> It is working fine fdor this ErrorGruop field value is "Article not present".

Can anyone please help me on this?  
Thanks in advance...

---

<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 20, 2020, 2:17pm UTC](https://discuss.elastic.co/t/scripted-field-not-working-on-some-of-the-strings/212853/2 "2020-01-20T14:17:08Z")

</div>

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