Skip to main content
jaredd697065
Participating Frequently
Sep 21, 2021 1:12 PM UTC
Question

Change All Values in a Dictionary to False

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
Participating Frequently
Sep 21, 2021 1:27 PM UTC

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
Participating Frequently
Sep 21, 2021 5:20 PM UTC

Worked just the way we needed it. Thank you!

stewart.burchell
Employee
Sep 21, 2021 1:30 PM UTC

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
Participating Frequently
Sep 21, 2021 5:20 PM UTC

We are using the latest version. Thanks!