Skip to main content
jaredd697065
September 21, 2021
Question

Change All Values in a Dictionary to False

  • September 21, 2021
  • 4 replies
  • 0 views

Hi everyone. Could someone help me with changing all the values in a dictionary? Basically, when a user clicks a a!dynamicLink we want all the values in a dictionary to go from TRUE to FALSE. I've tried using a loop with no success. 

Any suggestions are appreciated.

4 replies

vimals
September 21, 2021

You can try something similar to below:

a!localVariables(
  local!items: {a!map(isActive: true), a!map(isActive: false()), a!map(isActive: true)},
  a!linkField(
    links: a!dynamicLink(
      label: "RESET",
      saveInto: {
        a!save(
          local!items.isActive,
          repeat( length(local!items), false())
        )
      }
    )
  )
)

jaredd697065
September 21, 2021

Worked just the way we needed it. Thank you!

stewart.burchell
September 21, 2021

What version of Appian are you running? There is the a!update() function that allows you to update individual attributes. Here's an example:

a!localVariables(
  local!data: {
    { id: 1, name: "A", isActive: true },
    { id: 2, name: "B", isActive: true }
  },
  a!forEach(
    items: local!data,
    expression: a!update(fv!item, "isActive", false)
  )
)

...and the result is:

[id:1,name:A,isActive:false]; [id:2,name:B,isActive:false]

jaredd697065
September 21, 2021

We are using the latest version. Thanks!