Skip to main content
January 19, 2024
Solved

a!update

  • January 19, 2024
  • 8 replies
  • 0 views

Update class 8 to 9

{
a!map(name: "X", class: 5, School: "ABC"),
a!map(name: "Y", class: 6, School: "ADC"),
a!map(name: "Z", class: 7, School: "AEC"),
a!map(name: "K", class: 8, School: "AFC")
}

    Best answer by venkatrea696188

      a!update(local!X[4],"class",9)

    8 replies

    venkatrea696188
    January 19, 2024

    what do you wanna achieve ? Can you tell us more about your requirement

    if you want to know how to use a!update function  refer to the below document.

    https://docs.appian.com/suite/help/23.4/fnc_array_a_update.html, (Update function let's you update an array value at particular index you provide.)

    January 19, 2024

    Hi venky,

    I want to promote only class 8 student  to 9

    when I try below code it is updating all the students.

    a!localVariables(
    local!a: {
    a!map(name: "X", class: 5, School: "ABC"),
    a!map(name: "Y", class: 6, School: "ADC"),
    a!map(name: "Z", class: 7, School: "AEC"),
    a!map(name: "K", class: 8, School: "AFC")
    },
    a!forEach(
    items: local!a,
    expression: a!update(
    data: fv!item,
    index: "class",
    value: 9
    )
    )

    )

    Thanks in Advance

    venkatrea696188
    January 19, 2024

      a!update(local!X[4],"class",9)

    jayaprakashr0001
    Participating Frequently
    January 19, 2024

    a!localVariables(
    local!data:{
    a!map(name: "X", class: 5, School: "ABC"),
    a!map(name: "Y", class: 6, School: "ADC"),
    a!map(name: "Z", class: 7, School: "AEC"),
    a!map(name: "K", class: 8, School: "AFC")
    },
    local!index:wherecontains(8,local!data.class),
    local!dataToUpdate:index(local!data,local!index,null),
    a!update(local!data,local!index,{name:local!dataToUpdate.name,class:9,School:local!dataToUpdate.School})
    
    
    )

    harshitb6843
    January 19, 2024

    jayaprakashr0001
    Participating Frequently
    January 19, 2024

    Thanks [mention:b8ea18cfbb2e4f6d841cf3c1d4d7420b:e9ed411860ed4f2ba0265705b8793d05]