Invalid index (0) for list: valid range is empty

Certified Associate Developer

Hi ,

I am getting below error the attached code when there I don't pass value for ri!gLLs. Can someone please help in resolving this.

"Expression evaluation error at function 'remove' [line 67]: Invalid index (0) for list: valid range is empty"

a!localVariables(
  /* Appending logged in user with GLLS from LUContacts if logged in user is GLL */
  local!isLoggedInUserGLL: rule!APN_distinct(
    if(
      rule!APN_isEmpty(ri!gLLs),
      {},
      if(
        and(
          not(
            contains(
              touniformstring(
                index(
                  a!groupMembers(
                    group: cons!RGRACSLBL_GROUP_AGLL,
                    direct: true(),
                    memberType: "USER"
                  ),
                  "data",
                  {}
                )
              ),
              touniformstring(ri!loggedInUser)
            )
          ),
          or(
            contains(
              touniformstring(
                index(
                  a!groupMembers(
                    group: cons!RGRACSLBL_GROUP_EU_LL_USERS,
                    direct: true(),
                    memberType: "USER"
                  ),
                  "data",
                  {}
                )
              ),
              touniformstring(ri!loggedInUser)
            ),
            contains(
              touniformstring(
                index(
                  a!groupMembers(
                    group: cons!RGRACSLBL_GROUP_WPL,
                    direct: true(),
                    memberType: "USER"
                  ),
                  "data",
                  {}
                )
              ),
              touniformstring(ri!loggedInUser)
            )
          )
        ),
        append(ri!gLLs, ri!loggedInUser),
        ri!gLLs
      )
    )
  ),
  /* Formatting GLLs text */
  local!glls: if(
    length(local!isLoggedInUserGLL) = 1,
    rule!APN_displayUser(local!isLoggedInUserGLL),
    joinarray(
      a!forEach(
        items: remove(
          rule!APN_distinct(local!isLoggedInUserGLL),
          length(
            rule!APN_distinct(local!isLoggedInUserGLL)
          )
        ),
        expression: split(rule!APN_displayUser(fv!item), ";")
      ),
      ", "
    ) & " and " & rule!APN_displayUser(
      difference(
        rule!APN_distinct(local!isLoggedInUserGLL),
        remove(
          rule!APN_distinct(local!isLoggedInUserGLL),
          length(
            rule!APN_distinct(local!isLoggedInUserGLL)
          )
        )
      )
    )
  ),
  if(
    contains(
      /* CCN */
      {
        cons!RGRACSLBL_NOTIFICATION_TYPES[1],
        cons!RGRACSLBL_NOTIFICATION_TYPES[16]
      },
      ri!notificationType
    ),
    joinarray(
      insert(
        split(
          "Please contact[GLL]directly for any questions regarding this CCN.",
          "[GLL]"
        ),
        local!glls,
        2
      ),
      " "
    ),
    if(
      contains(
        /* Pre-sMA, Revised Pre-sMA */
        {
          cons!RGRACSLBL_NOTIFICATION_TYPES[7],
          cons!RGRACSLBL_NOTIFICATION_TYPES[25]
        },
        ri!notificationType
      ),
      substitute(
        cons!RGRACSLBL_PRE_SMA_AGLL_RICH_TEXT_CONSTANTS[7],
        "[GLL]",
        local!gLLs
      ) & " " & cons!RGRACSLBL_PRE_SMA_AGLL_RICH_TEXT_CONSTANTS[8],
      if(
        contains(
          /* Core SLU */
          {
            cons!RGRACSLBL_NOTIFICATION_TYPES[18],
            cons!RGRACSLBL_NOTIFICATION_TYPES[6]
          },
          ri!notificationType
        ),
        "Please contact " & local!glls & " directly for any questions regarding this update.",
        if(
          ri!notificationType = cons!RGRACSLBL_HQ_INITIATED_NON_SAFETY_LABEL_UPDATE_NOTIFICATION_TYPE,
          /* Non-Safety */
          joinarray(
            insert(
              split(
                cons!RGRACSLBL_TEXT_HQ_NONSAFETY_FREETEXT,
                "[GLL]"
              ),
              local!glls,
              2
            ),
            " "
          ),
          if(
            contains(
              /* Advisory */
              {
                cons!RGRACSLBL_NOTIFICATION_TYPES[9],
                cons!RGRACSLBL_NOTIFICATION_TYPES[17]
              },
              ri!notificationType
            ),
            joinarray(
              insert(
                split(
                  "Please contact[GLL]directly for any questions regarding this Advisory.",
                  "[GLL]"
                ),
                local!glls,
                2
              ),
              " "
            ),
            {}
          )
        )
      )
    )
  )
)

  Discussion posts and replies are publicly visible