`Optional Bool` field value in Navigator frontend-config.js?
- gyorgybalazsiOP
Can any of you tell me how I can query an
Optional Boolfield value in Navigator frontend-config.js? - Robert_Autenrieth 2
The following examples assume that you are familiar with the basics of
frontend-config.js, and that you have a contract fieldactive : Option Bool
In general,
Optionfields are serialized to:-
nullif their value isNone - the corresponding serialization of
xif their value isSome x
Option Boolis therefore serialized to eithernull,true, orfalse.
If you want to filter by the boolean field, use the following blocks. To only display contracts where the
activefield isSome TrueorSome False, use:filter: [ { field: "argument.active", value: "Some", } ],To only display contracts where the
activefield isSome 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"forNonevalues,"Yes"forSome Truevalues, and"No"forSome Falsevalues.{ 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" } -
- bernhard
Robert_Autenrieth:If you want to filter by the boolean field, use the following block. It will only display contracts where the
activefield equals toSome True.filter: [ { field: "argument.active", value: "true", } ],@Robert_Autenrieth did you test this? I don’t think that’s true. Putting
"None"and"Some", intovaluecorrectly filters those values that areNoneorSome. Putting in"true","false"or"null"does not work for me. - Robert_Autenrieth
@bernhard Thanks for checking! I had initially tested my answer with a
Boolfield, and only realized later that the question is aboutOption 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
activefield isSome TrueorSome False, use:filter: [ { field: "argument.active", value: "Some", } ],To only display contracts where the
activefield isSome True, use:filter: [ { field: "argument.active.Some", value: "true", } ], - gyorgybalazsi
Thank you @Robert_Autenrieth and @bernhard, works perfectly, this time I need the custom column version, but also noted the filter code