need convert the code having nested If conditions to Foreach()

Hi Team,

Could you please help me in converting the following code into Foreach()

if(
          isnull(
            local!region
          ),
          if(
            rule!APN_isEmpty(
              tostring(
                index(
                  local!userlist.data,
                  "regionId",
                  {}
                )
              )
            ),
            if(
              rule!APN_isEmpty(
                tostring(
                  index(
                    local!userlist.data,
                    "lobId",
                    {}
                  )
                )
              ),
              if(
                rule!APN_isEmpty(
                  tostring(
                    index(
                      local!userreg.data,
                      "regionId",
                      {}
                    )
                  )
                ),
                {},
                local!distuserregname
              ),
              null
            ),
            tostring(
              rule!CTR_QE_getRegionNameByRegionId(
                index(
                  local!userlist.data,
                  "regionId",
                  {}
                )
              )
            )
          ),
          local!region
        )

Thanks in advance.

  Discussion posts and replies are publicly visible

  • My issue got resolved with the following query.

    a!forEach(
            items: local!userlist.data,
            expression: if(
              isnull(
                local!region
              ),
              if(
                rule!APN_isEmpty(
                  tostring(
                    index(
                      fv!item,
                      "regionId",
                      {}
                    )
                  )
                ),
                if(
                  rule!APN_isEmpty(
                    tostring(
                      index(
                        fv!item,
                        "lobId",
                        {}
                      )
                    )
                  ),
                  if(
                    rule!APN_isEmpty(
                      tostring(
                        index(
                          local!userreg.data,
                          "regionId",
                          {}
                        )
                      )
                    ),
                    {},
                    local!distuserregname
                  ),
                  null
                ),
                tostring(
                  rule!CTR_QE_getRegionNameByRegionId(
                    index(
                      fv!item,
                      "regionId",
                      {}
                    )
                  )
                )
              ),
              local!region
            ),
          )