Skip to main content
kavyam0002
February 20, 2024
Solved

append

  • February 20, 2024
  • 6 replies
  • 2 views

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 

    Best answer by stewart.burchell

    You can use the a!update() function, something like this:

    a!localVariables(
      local!query1Result: a!map(id: 54, class: "B", owner: "xyz"),
      local!query2Result: a!map(id: 54, owner: "abc"),
      a!update(
        local!query1Result,
        "owner",
        local!query2Result.owner
      )
    )
     

    6 replies

    stewart.burchell
    February 20, 2024

    You can use the a!update() function, something like this:

    a!localVariables(
      local!query1Result: a!map(id: 54, class: "B", owner: "xyz"),
      local!query2Result: a!map(id: 54, owner: "abc"),
      a!update(
        local!query1Result,
        "owner",
        local!query2Result.owner
      )
    )
     

    kavyam0002
    February 20, 2024

    if query1 has list, like

    id :54, class: b, owner :"xyz

    id:54, class:a, owner:"pqr

    in this case i have to update id=54 and class : b owner then how can i write 

    mathieud0001
    Brainy
    February 20, 2024

    You could also do a custom record field based on the relationship between the Record used in query 1 and the Record used in query 2.

    docs.appian.com/.../fnc_crf_customfielddefaultvalue.html

    dhananjayk3480
    February 20, 2024

    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))
    )
    )
    )
    )
    )
    )

    March 5, 2024

    I also wanted to ask the same, thank you so much. Thanks for answering, you made my day. While searching for it online, I also found academized.com/write-my-case-study website link where I found an essay writer who will write my case study for me by taking some money. Now, I won't take to much time to write my essay assignments.

    March 5, 2024

    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, class: "F")
      },
      local!getIndex: cast(
        typeof({ 1 }),
        index(local!query2Result, "id", null)
      ),
      a!forEach(
        items: local!query1Result,
        expression: if(
          contains(
            local!getIndex,
            tointeger(index(fv!item, "id", null)),
    
          ),
          a!localVariables(
            local!data:index(
              local!query2Result,
              wherecontains(
                tointeger(index(fv!item, "id", null)),
                local!getIndex
              )
            ),
            local!keys: a!keys(
             cast(typeof(a!map()), 
             index(
                local!query2Result,
                wherecontains(
                  tointeger(index(fv!item, "id", null)),
                  local!getIndex
                )
              )
             )
            ),
            a!update(
             data: local!data,
            index:  local!keys,
             value:touniformstring(index(
               fv!item,
               {local!keys}
             ))
            )
          ),
          fv!item
        )
      )
    )