How to check for null when passing parameters

I have a button event that opens a dialog and passes parameters. However, when the form field is null, the button doesn’t work. How do I check for nulls in a parameter that is trying to pass ${annexation.ORDINANCE_NO} where ORDINANCE_NO is null?

Hi,

One way to deal with this is to initialize the form field to a non null value. We can help more if we see the code of the page. Can you paste the JSON? It would be in the meta\pages directory.

Best,
Atanas

This is an existing database, so I don’t think I want to mess with the null values.

Here’s the JSON (the button is called “Duplicate”):
{
“components”: [
{
“components”: [
{
“class”: “col-md-12”,
“components”: [
{
“events”: {
“click”: [
{
“parameters”: [
{
“name”: “PICTURE”,
“value”: “${annexation.PICTURE}”
},
{
“name”: “ANNEX_YEAR”,
“value”: “${annexation.ANNEX_YEAR}”
},
{
“name”: “ANNEX_DATE”,
“value”: “${annexation.ANNEX_DATE}”
},
{
“name”: “ACRES”,
“value”: “${annexation.ACRES}”
},
{
“name”: “ANNEX_NAME”,
“value”: “${annexation.ANNEX_NAME}”
},
{
“name”: “ORDINANCE_NO”,
“value”: “${annexation.ORDINANCE_NO}”
},
{
“name”: “ANNEX_NO”,
“value”: “${annexation.ANNEX_NO}”
}
],
“path”: “add-annexation-copy”,
“type”: “popup”
}
]
},
“icon”: “”,
“name”: “button0”,
“text”: “Duplicate”,
“type”: “button”
}
],
“name”: “col0”,
“type”: “col”
},
{
“class”: “col-md-12”,
“components”: [
{
“data”: “${annexation}”,
“events”: {
“cancel”: [
{
“type”: “back”
}
],
“submit”: [
{
“error”: [
{
“detail”: “Unable to update Annexation”,
“severity”: “error”,
“summary”: “Error”,
“type”: “notify”
}
],
“name”: “GJFilesAdmin.updateAnnexation”,
“parameters”: [
{
“name”: “OBJNUM”,
“value”: “${parameters.OBJNUM}”
},
{
“name”: “Annexation”,
“value”: “${event}”
}
],
“then”: [
{
“path”: “annexations”,
“type”: “navigate”
}
],
“type”: “invoke”
}
]
},
“fields”: [
{
“disabled”: true,
“property”: “PICTURE”,
“required”: false,
“requiredText”: “is required”,
“title”: “FILE NUMBER”,
“type”: “string”
},
{
“property”: “ANNEX_YEAR”,
“required”: false,
“requiredText”: “is required”,
“title”: “ANNEX YEAR”,
“type”: “number”
},
{
“property”: “ANNEX_DATE”,
“required”: false,
“requiredText”: “is required”,
“title”: “ANNEX DATE”,
“type”: “date”
},
{
“property”: “ACRES”,
“required”: false,
“requiredText”: “is required”,
“title”: “ACRES”,
“type”: “number”
},
{
“property”: “ANNEX_NAME”,
“required”: false,
“requiredText”: “is required”,
“title”: “ANNEX NAME”,
“type”: “string”
},
{
“property”: “ORDINANCE_NO”,
“required”: false,
“requiredText”: “is required”,
“title”: “ORDINANCE NO”,
“type”: “number”
},
{
“property”: “ANNEX_NO”,
“required”: false,
“requiredText”: “is required”,
“title”: “ANNEX NO”,
“type”: “number”
}
],
“name”: “form0”,
“type”: “form”
}
],
“type”: “col”
}
],
“type”: “row”
}
],
“events”: {
“load”: [
{
“name”: “GJFilesAdmin.getAnnexationByOBJNUM”,
“parameters”: [
{
“name”: “OBJNUM”,
“value”: “${parameters.OBJNUM}”
}
],
“then”: [
{
“name”: “annexation”,
“type”: “set”,
“value”: “${result}”
}
],
“type”: “invoke”
}
]
},
“name”: “Edit Annexation”,
“access”: [
“Authenticated”
]
}

Thanks!

I see what you mean. Indeed the Angular router components needs a non-null parameter value otherwise it would just skip it.

You can provide a non-null value for a parameter like this:

${annexation.ORDINANCE_NO || 'defaultValue'}

Cool. As usual you provide the solution. Thanks.