# How to set binary field in SN from Jira SD?

**URL:** https://community.exalate.com/t/how-to-set-binary-field-in-sn-from-jira-sd/4641
**Category:** General Questions
**Tags:** jira-snowintegration, migrated\_question, jira-servicenow-inte
**Created:** [November 4, 2024, 7:12am UTC](https://community.exalate.com/t/how-to-set-binary-field-in-sn-from-jira-sd/4641 "2024-11-04T07:12:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)
#### Post date: [November 4, 2024, 7:12am UTC](https://community.exalate.com/t/how-to-set-binary-field-in-sn-from-jira-sd/4641/1 "2024-11-04T07:12:29Z")

</div>

_Originally asked by Andrew on 15 March 2021 [(original question)](https://oldcommunity.exalate.com/questions/25069756)_

* * *

Hello community,

I have following payload from Jira SD:

```auto
"MoMe-Flag": {  
   "id": 11816,  
   "name": "MoMe-Flag",  
   "description": "for MoMe",  
   "type": "OPTIONS",  
   "value": [  
      {

```

```auto
        "id": "12399",  
        "sequence": 0,  
        "value": "Yes",  
        "disabled": false,  
        "childOptions": []  
      }  
   ]  
}

```

I have following incoming script on SN side:

`if (replica.customFields."MoMe-Flag"?.value?.value == "Yes") {`

`incident.u_mome = true`

`} else {`

`incident.u_mome = false`

`}`

but it doesn’t set u\_mome field = true from above payload. u\_mome is boolean type field.

Hopefully, someone can help.

* * *

---

<div class="post-metadata">

### Author: ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)
#### Post date: [November 4, 2024, 7:12am UTC](https://community.exalate.com/t/how-to-set-binary-field-in-sn-from-jira-sd/4641/2 "2024-11-04T07:12:31Z")

</div>

_Answer by Francis Martens (Exalate) on 16 March 2021_

Are there any business rules around that field?  
We have seen this in a number of cases where the business rule consequence is that ServiceNow silently ignores the update.

* * *

#### Comments:

> **Andrew commented on 16 March 2021**
>
> > I did not find business rule around the field. `incident.u_mome` is new custom field.
> 
> When I added below two lines to my script, I was able to update description field with sent binary value:
> 
> def mome = replica.customFields.“MoMe-Flag”?.value?.value  
> incident.description = "MoMe: " + mome
> 
> and then description is **MoMe: [Yes]**
> 
> So I am able to display boolean value in text field, bt I cannot set with this value boolean field.

> **Francis Martens (Exalate) commented on 16 March 2021**
>
> > Ah - replica.customFields.“MoMe-Flag”?.value?.value is an array.  
> > Can it be that it is a multi value field?
> 
> Following code takes into account that
> 
> - flag is null → false
> - flag is empty → false
> - flag has a value ‘true’ → true
> 
> It is untested … but should work
> 
> **Untested**
> 
> ```auto
> def flag = replica.customFields."MoMe-Flag"?.value?.value
> incident.u_mome = flag?.size ? (flag[0] == "true") : false
> 
> ```

> **Andrew commented on 17 March 2021**
>
> > Hello,
> 
> Positive payload is above, negative (or rather empty) payload from Jira is below:
> 
> ```auto
> "MoMe-Flag": {          
> "id": 11816,          
> "name": "MoMe-Flag",          
> "description": "for MoMe",          
> "type": "OPTIONS",          
> "value": [] },
> 
> ```
> 
> I have added to incoming script with some “diagnostic” features as below:
> 
> `def mome = replica.customFields."MoMe-Flag"?.value?.value.toString()`
> 
> `def flag1 = replica.customFields."MoMe-Flag"?.value?.value`
> 
> `def flag2 = flag1?.size ? (flag1[0] == "true") : false`
> 
> `if (mome == "[Yes]") {`
> 
> `incident.description = "1. mome true" + "\n" + "2. MoMe: " + mome + "\n" + "3. Flag1: " + flag1 + "\n" + "4. Flag2: " + flag2`
> 
> `incident.u_mome = flag1?.size ? (flag1[0] == "true") : false`
> 
> `} else {`
> 
> `incident.description = "a. mome false" + "\n" + "b. MoMe: " + mome + "\n" + "c. Flag1: " + flag1 + "\n" + "d. Flag2: " + flag2`
> 
> `incident.u_mome = flag1?.size ? (flag1[0] == "true") : false`
> 
> `}`
> 
> So description field for positive payload looks as below:
> 
> 1. mome true
> 2. MoMe: [Yes]
> 3. Flag1: [Yes]
> 4. Flag2: false
> 
> and for empty payload like here:
> 
> a. mome false
> 
> b. MoMe:
> 
> c. Flag1:
> 
> d. Flag2: false
> 
> So flag2 is always false and u\_mome field is not updated to true.

> **Francis Martens (Exalate) commented on 18 March 2021**
>
> > Check the logic.
> 
> flag2 will always be false because flag1 has the value ‘Yes’ and not true. So the expression  
> flag1[0] == “true”
> 
> Will always return false …

> **Andrew commented on 22 March 2021**
>
> > Yes, you are right Francis.
> 
> I’ve corrected script so now is:
> 
> ```auto
> def flag2 = flag1?.size ? (flag1[0] == "Yes") : false
> 
> ```
> 
> and
> 
> ```auto
> incident.u_mome = flag1?.size ? (flag1[0] == "Yes") : false
> 
> ```
> 
> so now flag2 = true
> 
> but incident.u\_mome still is false

> **Francis Martens (Exalate) commented on 22 March 2021**
>
> > Can you try without the expression
> 
> ```auto
> incident.u_mome = true
> 
> ```
> 
> And see if this is accepted by ServiceNow. There might be a business rule ignoring the value.
