Skip to main content
tajinders0001
December 9, 2021
Question

Index attribute within a!update() function seems to be case insensitive

  • December 9, 2021
  • 3 replies
  • 0 views

We often use a!update() function to update dictionary values however, it fails when a dictionary has 2 attributes with different font cases (e.g. label & LABEL)

In 21.4 I tried using the a!update() function as below:

Input

{
label:"",
LABEL:"asdf",
label3:"",
label4:"asdf"
}

Rule
a!update(ri!dict,"LABEL",123)

Output: 

{label: 123, LABEL: "asdf", label3: "", label4: "asdf"}

Is there another function that I can use to avoid this? I do not want to recreate the entire dictionary each time someone updates a single value.

3 replies

tajinders0001
December 9, 2021

I am specifically using dictionary type (and not MAP type) to avoid getting the duplicate label error.

December 9, 2021

Based on the documentation, this is a limitation of a!update() function.

https://docs.appian.com/suite/help/21.4/fnc_array_a_update.html

Limitations and alternatives

  • Do not use maps, dictionaries, CDTs, or records which contain fields that differ only in casing.

 

You can use updateDictionary() function from the "Dictionary Manipulation" plugin which gives the desired result.

https://community.appian.com/b/appmarket/posts/cdt-manipulation

updatedictionary(
  dictionary:  ri!dict,
  fieldsAndValues: {
    "LABEL": 123
  }
)

andrewh0007
December 9, 2021

If you don't care about the order of your dictionary you can use the below code. This was just a quick formulation so if the order is important I'm sure this could be achieved as well as validation checks to see if a!update() would work. But this at least proves the concept.

Appian is a little inconsistent with what is and isn't case sensitive. For example if you're checking for a valid username before creating a user using the isusernametaken() function then this is case sensitive. But account creation is case insensitive so if you check for "Appian" and it's available your user creation may still fail if there is a user "appian" (or any permutation where only the case differs). Frustrating.

a!localVariables(
  local!data: {
    label:"",
    LABEL:"asdf",
    label3:"",
    label4:"asdf"
  },
  local!fieldToUpdate: "LABEL",
  local!newValue: 123,
  insert(
    remove(
      local!data,
      local!fieldToUpdate
    ),
    local!newValue,
    local!fieldToUpdate
  )
)