Skip to main content
chrisg0006
May 23, 2025
Solved

It appears that a!isnotnullorempty is not working the way I think it should.

  • May 23, 2025
  • 9 replies
  • 0 views

I have a portal (yes a real portal) where parishes set their preferences for a speaker for Mission Co-Op Mission Sunday.

The interface has a dropdown where they select the parish they want to set preferences and sets a local variable, slectedParish.  Once the parish is selected, I load a local variable, selectedParishProfile. 

local!selectedParishProfile: if(
    a!isNotNullOrEmpty(local!selectedParish),
    rule!PMSO_getParishProfilebyParishID(local!selectedParish),
    null
  ),

Now, the parish may or may not have an existing profile. So the expression rule either returns the profile or null if one does not exist.

In the interface, I have a radio button field.  

a!radioButtonField(
    choiceLabels: { "Yes", "No" },
    choiceValues: { true, false },
    label: "Can the Parish Provide Lodging?",
    labelPosition: "ABOVE",
    value: local!selectedParishProfile[PMSO Parish Profile.fields.parishLodgingType'],
    saveInto:  local!selectedParishProfile[PMSO Parish Profile.fields.parishLodgingType'],
    required: true,
    choiceLayout: "COMPACT",
    choiceStyle: "STANDARD",
    spacing: "EVEN_MORE"
 ),

Now this throws an error when I select a parish that does not have a parish profile because the value is Null.

"A radio button component [label="Can the Parish Provide Lodging?"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was Rectory and choiceValues was true; false."

Therefore, I created a local variable parishLodging to set a default and use that in the Radio Button.

local!parishlodging: if(
    a!isNotNullOrEmpty(
    local!selectedParishProfile['recordType!PMSO Parish Profile.fields.parishLodging']
     ),
    local!selectedParishProfile['recordType!PMSO Parish Profile.fields.parishLodging'],
    false
 ),

This works until I start entering data into the selectedParishProfile record.  For some reason, the local variable parishLodging is changed from false to Null.  I don't understand why.  The a!isNotNullorEmpty function should see that the field is still Null and it should be set to false.

What am I missing here?

Best answer by stefanhelzle0001

In our coding guidelines, we have a strict rule: If an expression, using singular naming, indicates that it returns a single item, then it must never return any kind of list.

9 replies

mikes0011
Brainy
May 23, 2025

What is the data type of the "parishLodging" record field?  If it's a boolean value (true/false) then I'd think this might work for you. 

What is your local!parishLodging value evaluating to when the record field has a value?  Is it accidentally evaluating to an array, or something else funny?  Some screenshots of your value fields might help, if you're unsure.

stefanhelzle0001
May 23, 2025

The error message very clearly states that this local is far from being null ...

mikes0011
Brainy
May 23, 2025
this local is far from being null ...

FWIW... i had this initial reaction too, but the rest of his post (if i'm reading it correctly) accounts for this.