append

i'll get list of data from one query, to that query data i have to map few fields value 

ex query1 gives :

id :54,  abc, class: B, owner :xyz

from second query from another table will get 

id:54, owner :abc

this second query owner data needs to update/show in query1 how can i achieve this 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    As Stewart said, we are supposed to use a!update () function but if its just one value updating you can use as suggested below but if its many and you want all of them to happen in one single logic then here you go: -

    a!localVariables(
    local!query1Result: {
    a!map(id: 54, class: "B", owner: "xyz"),
    a!map(id: 55, class: "C", owner: "abc"),
    a!map(id: 56, class: "D", owner: "mno"),
    a!map(id: 57, class: "E", owner: "ghi")
    },
    local!query2Result: { a!map(id: 54, owner: "help"), a!map(id: 57) },
    a!forEach(
    items: local!query1Result,
    expression: a!localVariables(
    local!toUpdateIndex: wherecontains(
    tointeger(index(fv!item, "id", null)),
    tointeger(index(local!query2Result, "id", null))
    ),
    local!toDo: if(
    a!isNullOrEmpty(local!toUpdateIndex),
    {},
    index(
    local!query2Result,
    local!toUpdateIndex,
    null
    )
    ),
    if(
    a!isNullOrEmpty(local!toDo),
    fv!item,
    a!update(
    fv!item,
    "owner",
    a!defaultValue(
    tostring(index(local!toDo, "owner", null)),
    tostring(index(fv!item, "owner", null))
    )
    )
    )
    )
    )
    )

Reply
  • +1
    Certified Lead Developer

    As Stewart said, we are supposed to use a!update () function but if its just one value updating you can use as suggested below but if its many and you want all of them to happen in one single logic then here you go: -

    a!localVariables(
    local!query1Result: {
    a!map(id: 54, class: "B", owner: "xyz"),
    a!map(id: 55, class: "C", owner: "abc"),
    a!map(id: 56, class: "D", owner: "mno"),
    a!map(id: 57, class: "E", owner: "ghi")
    },
    local!query2Result: { a!map(id: 54, owner: "help"), a!map(id: 57) },
    a!forEach(
    items: local!query1Result,
    expression: a!localVariables(
    local!toUpdateIndex: wherecontains(
    tointeger(index(fv!item, "id", null)),
    tointeger(index(local!query2Result, "id", null))
    ),
    local!toDo: if(
    a!isNullOrEmpty(local!toUpdateIndex),
    {},
    index(
    local!query2Result,
    local!toUpdateIndex,
    null
    )
    ),
    if(
    a!isNullOrEmpty(local!toDo),
    fv!item,
    a!update(
    fv!item,
    "owner",
    a!defaultValue(
    tostring(index(local!toDo, "owner", null)),
    tostring(index(fv!item, "owner", null))
    )
    )
    )
    )
    )
    )

Children
No Data