# \`Optional Bool\` field value in Navigator frontend-config.js?

**URL:** <https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741>\
**Category:** App Development\
**Created:** [June 26, 2020, 3:11pm UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741 "2020-06-26T15:11:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [June 26, 2020, 3:11pm UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741/1 "2020-06-26T15:11:29Z")

</div>

Can any of you tell me how I can query an `Optional Bool` field value in Navigator frontend-config.js?

---

<div class="post-metadata">

**Author:** ![Robert\_Autenrieth](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/robert_autenrieth/32/153_2.png) [@Robert\_Autenrieth](https://forum.canton.network/u/Robert_Autenrieth)\
**Post date:** [June 29, 2020, 9:57am UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741/2 "2020-06-29T09:57:51Z")

</div>

The following examples assume that you are familiar with the basics of `frontend-config.js`, and that you have a contract field

```
    active : Option Bool

```

* * *

In general, `Option` fields are serialized to:

- `null` if their value is `None`
- the corresponding serialization of `x` if their value is `Some x`

`Option Bool` is therefore serialized to either `null`, `true`, or `false`.

* * *

If you want to filter by the boolean field, use the following blocks. To only display contracts where the `active` field is `Some True` or `Some False`, use:

```
filter: [
  {
    field: "argument.active",
    value: "Some",
  }
],

```

To only display contracts where the `active` field is `Some True`, use:

```
filter: [
  {
    field: "argument.active.Some",
    value: "true",
  }
],

```

* * *

If you want to display the boolean value in a custom column, use the following block. It will print `"N/A"` for `None` values, `"Yes"` for `Some True` values, and `"No"` for `Some False` values.

```
{
  key: "argument.active",
  title: "Active",
  createCell: ({rowData}) => {
    const value = DamlLfValue.toJSON(rowData.argument).active;
    return {
      type: "text",
      value: value === null ? "N/A" : value === true ? "Yes" : "No"
    }
  },
  sortable: true,
  width: 80,
  weight: 3,
  alignment: "left"
}
```

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [June 29, 2020, 10:16am UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741/3 "2020-06-29T10:16:11Z")

</div>

> [@Robert\_Autenrieth](#):
>
> If you want to filter by the boolean field, use the following block. It will only display contracts where the `active` field equals to `Some True` .
> 
> ```haskell
> filter: [
> {
> field: "argument.active",
> value: "true",
> }
> ],
> 
> ```

@Robert_Autenrieth did you test this? I don’t think that’s true. Putting `"None"` and `"Some"`, into `value` correctly filters those values that are `None` or `Some`. Putting in `"true"`, `"false"` or `"null"` does not work for me.

---

<div class="post-metadata">

**Author:** ![Robert\_Autenrieth](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/robert_autenrieth/32/153_2.png) [@Robert\_Autenrieth](https://forum.canton.network/u/Robert_Autenrieth)\
**Post date:** [June 29, 2020, 10:27am UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741/4 "2020-06-29T10:27:01Z")

</div>

@bernhard Thanks for checking! I had initially tested my answer with a `Bool` field, and only realized later that the question is about `Option Bool`.

The code for the custom display is still correct. The code for filtering contracts is wrong, here are correct examples:

To only display contracts where the `active` field is `Some True` or `Some False`, use:

```
filter: [
  {
    field: "argument.active",
    value: "Some",
  }
],

```

To only display contracts where the `active` field is `Some True`, use:

```
filter: [
  {
    field: "argument.active.Some",
    value: "true",
  }
],
```

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [June 29, 2020, 12:24pm UTC](https://forum.canton.network/t/optional-bool-field-value-in-navigator-frontend-config-js/741/5 "2020-06-29T12:24:57Z")

</div>

Thank you @Robert_Autenrieth and @bernhard, works perfectly, this time I need the custom column version, but also noted the filter code
