Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

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

Parents
  • 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
            ),
          )

Reply
  • 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
            ),
          )

Children
No Data