Skip to main content
saahilm4696
May 11, 2023
Solved

Nested index() issue in User Interface "Design Mode"

  • May 11, 2023
  • 3 replies
  • 0 views

Hi all,

I have encountered an issue in an interface while switching from expression mode to design mode in Appian. The issue is mainly cause of nested indexing (An alternate approach that I have used in UI). Below are 2 code snippets, while switching to design mode, the second snippet causes the error to appear.

I am trying to use a single index() instead of nested index(), is there any sort of performance difference between these two approaches, or any benefit of one over the other?

a!localVariables(
  local!list: {
    a!map(key: "test1"),
    a!map(key: "test2"),
    a!map(key: "test3")
  },
  a!textField(
    value: index(index(local!list, 1, {}), "key", {})
  )
)
/* Works well */

a!localVariables(
  local!list: {
    a!map(key: "test1"),
    a!map(key: "test2"),
    a!map(key: "test3")
  },
  a!textField(value: index(local!list, 1, "key", {}))
)
/* Gives error in switching to design mode */

Error:

Cannot switch to Design Mode

The function 'index' [line 7] has 3 parameter(s), but instead passed 4 parameter(s).

Best answer by sanchitg0002

This way of using index function is neither recommended nor documented by Appian and you should also avoid using it as there is no certainty when it will get removed or stop working. According to Appian, it can take only 2, or at most 3 parameters including the default and no more. This is the reason why Design mode is not able to handle this situation.

3 replies

May 11, 2023

This way of using index function is neither recommended nor documented by Appian and you should also avoid using it as there is no certainty when it will get removed or stop working. According to Appian, it can take only 2, or at most 3 parameters including the default and no more. This is the reason why Design mode is not able to handle this situation.

mikes0011
Brainy
May 11, 2023
I am trying to use a single index() instead of nested index(),
  1. don't do this - as Sanchit correctly pointed out it's not supported (and may only work by accident)
  2. don't use index() for returning a property in general, use property() for that, and use index() for array indexes - especially when nesting - unless you're actually aiming for code that's harder to read overall.
The Expression Guru
saahilm4696
May 12, 2023

Got it, I don't remember where I saw this method as a shortcut for nested index().

Thanks [emoticon:c4563cd7d5574777a71c318021cbbcc8]