Skip to main content
Inspiring
Nov 16, 2023 8:45 AM UTC
Solved

Getting error "Null argument not allowed"

I have below expression to get the country groups without groups ids. It is working fine when I pass the country name without special characters. 

if(
  rule!APN_isBlank(ri!countryName),
  {},
  a!forEach(
    items: ri!countryName,
    expression: rule!APN_replaceNull(
      nullableValue: group(
        tointeger(getgroupbyname("RGRACSLBL_" & fv!item)),
        "groupName"
      ),
      replacementValue: group(
        tointeger(
          getgroupbyname(
            "RGRACSLBL_" & stripwith(
              fv!item,
              joinarray(cons!RGRACSLBL_SPECIAL_CHARACTERS, "")
            )
          )
        ),
        "groupName"
      )
    )
  )
)

But I'm getting below error when I pass a country with special character even though I have special character check in the code. Please help in resolving the error. 

For example the country name with special characters : "Bolivia, Plurinational State of", I should get the group name as "RGRACSLBL_Bolivia Plurinational State of"

    stefanhelzle0001
    Brainy
    Nov 16, 2023 8:54 AM UTC

    The issue here is that the group() function does not like NULL values. If getgroupbyname does not return anything, you run inti this issue. Changing your code like this might help. I can not test it and it might contain typos of missing commas.

    if(
      rule!APN_isBlank(ri!countryName),
      {},
      a!forEach(
        items: ri!countryName,
        expression: group(
          rule!APN_replaceNull(
            nullableValue: tointeger(getgroupbyname("RGRACSLBL_" & fv!item)),
            replacementValue: tointeger(
              getgroupbyname(
                "RGRACSLBL_" & stripwith(
                  fv!item,
                  joinarray(cons!RGRACSLBL_SPECIAL_CHARACTERS, "")
                )
              )
           )
         ),
         "groupName"
      )
    )

    2 replies

    stefanhelzle0001
    Brainy
    Nov 16, 2023 8:54 AM UTC

    The issue here is that the group() function does not like NULL values. If getgroupbyname does not return anything, you run inti this issue. Changing your code like this might help. I can not test it and it might contain typos of missing commas.

    if(
      rule!APN_isBlank(ri!countryName),
      {},
      a!forEach(
        items: ri!countryName,
        expression: group(
          rule!APN_replaceNull(
            nullableValue: tointeger(getgroupbyname("RGRACSLBL_" & fv!item)),
            replacementValue: tointeger(
              getgroupbyname(
                "RGRACSLBL_" & stripwith(
                  fv!item,
                  joinarray(cons!RGRACSLBL_SPECIAL_CHARACTERS, "")
                )
              )
           )
         ),
         "groupName"
      )
    )

    Inspiring
    Nov 16, 2023 8:57 AM UTC

    Thank you [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05] This solved my error