Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

How can I save the value in different indexes ?

Here, If I give quantity value for 1st row then it is coming to all the rows with the same value. Item, ItemName, Price, are in one Rule input and Quantity, Total are belongs to other Ruleinput.
How can I save the Quantity value in their indexes ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Instead of a normal local variable, you have to create it with the Map function. Please find the attached code for reference.

    a!localVariables(
      local!items: {
        a!map(item: "3", itemName: "Bag", price: "1000"),
        a!map(
          item: "1",
          itemName: "Laptop",
          price: "50000"
        ),
        a!map(item: "3", itemName: "Bag", price: "1000")
      },
      local!quanPrice: a!forEach(
        items: local!items,
        expression: {
          {
            a!map(
              quantity: 10,
              total: tointeger(fv!item.price) * 10
            )
          }
        }
      ),
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Item Name"),
          a!gridLayoutHeaderCell(label: "Price"),
          a!gridLayoutHeaderCell(label: "Quantity"),
          a!gridLayoutHeaderCell(label: "Total")
        },
        rows: a!forEach(
          items: local!items,
          expression: {
            a!gridRowLayout(
              id: fv!index,
              contents: {
                a!textField(
                  value: fv!item.item,
                  saveInto: fv!item.item,
                  readOnly: true()
                ),
                a!textField(
                  value: fv!item.itemName,
                  saveInto: fv!item.itemName,
                  readOnly: true()
                ),
                a!textField(
                  value: fv!item.price,
                  saveInto: fv!item.price,
                  readOnly: true()
                ),
                a!textField(
                  value: local!quanPrice[fv!index].quantity,
                  saveInto: local!quanPrice[fv!index].quantity,
                  
                ),
                a!textField(
                  value: local!quanPrice[fv!index].total,
                  saveInto: local!quanPrice[fv!index].total,
                  
                )
              }
            )
          }
        )
      )
    )

Reply
  • 0
    Certified Lead Developer

    Instead of a normal local variable, you have to create it with the Map function. Please find the attached code for reference.

    a!localVariables(
      local!items: {
        a!map(item: "3", itemName: "Bag", price: "1000"),
        a!map(
          item: "1",
          itemName: "Laptop",
          price: "50000"
        ),
        a!map(item: "3", itemName: "Bag", price: "1000")
      },
      local!quanPrice: a!forEach(
        items: local!items,
        expression: {
          {
            a!map(
              quantity: 10,
              total: tointeger(fv!item.price) * 10
            )
          }
        }
      ),
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Item Name"),
          a!gridLayoutHeaderCell(label: "Price"),
          a!gridLayoutHeaderCell(label: "Quantity"),
          a!gridLayoutHeaderCell(label: "Total")
        },
        rows: a!forEach(
          items: local!items,
          expression: {
            a!gridRowLayout(
              id: fv!index,
              contents: {
                a!textField(
                  value: fv!item.item,
                  saveInto: fv!item.item,
                  readOnly: true()
                ),
                a!textField(
                  value: fv!item.itemName,
                  saveInto: fv!item.itemName,
                  readOnly: true()
                ),
                a!textField(
                  value: fv!item.price,
                  saveInto: fv!item.price,
                  readOnly: true()
                ),
                a!textField(
                  value: local!quanPrice[fv!index].quantity,
                  saveInto: local!quanPrice[fv!index].quantity,
                  
                ),
                a!textField(
                  value: local!quanPrice[fv!index].total,
                  saveInto: local!quanPrice[fv!index].total,
                  
                )
              }
            )
          }
        )
      )
    )

Children
No Data