Skip to main content
November 16, 2023
Solved

Getting error "Null argument not allowed"

  • November 16, 2023
  • 2 replies
  • 0 views

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"

    Best answer by stefanhelzle0001

    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
    November 16, 2023

    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"
      )
    )

    November 16, 2023

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