Multiple Inputs and storing : Appian interface

Certified Associate Developer


Hi ,

I have created a interface in which when I selected a product in "Add product in Cart", It should be populated in Picked products and will show quantity input field. But I don't know  how to store the quantity input  values for different quantity fields, for example If I give quantity value 12 for Soaps it is showing 12 for all product's quantity.

Thanks in advance.

Code for the same below:

a!formLayout(
label: "Buy Products",
contents: {
a!sectionLayout(
contents: {
a!richTextDisplayField(
label: "User",
labelPosition: "JUSTIFIED",
value: user(loggedInUser(), "firstName")
)
}
),
a!sectionLayout(
label: "Add Products in Cart",
contents: {
a!sectionLayout(
label: "",
contents: {
a!pickerFieldRecords(
label: "Pick Products",
labelPosition: "ABOVE",
maxSelections: 20,
recordType: 'recordType!{886fbcf9-c44b-4cc9-bb6e-76529b93d6e5}TS_RecordType_Product',
value: ri!productsSelected,
saveInto: ri!productsSelected,
validations: {}
)
}
),
a!sectionLayout(
label: "Picked Products",
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!forEach(
ri!productsSelected,
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: index(
a!queryEntity(
entity: cons!TS_Constant_Product,
query: a!query(
selection: a!querySelection(
columns: { a!queryColumn(field: "productName") }
),
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "ID",
operator: "=",
value: tointeger(fv!item)
)
},
ignoreFiltersWithEmptyValues: true
),
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50)
),
fetchTotalCount: false
).data,
"productName"
)
)
}
),
a!columnLayout(
contents: {
a!textField(
label: "Quantity",
labelPosition: "JUSTIFIED",
value: {},
saveInto: {},
refreshAfter: "UNFOCUS",
validations: {}
)
}
),
a!columnLayout(contents: {})
}
)
)
}
),

}
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
submit: true,
style: "PRIMARY"
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}
)
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You should consider making your "order" a CDT object, so that instead of just populating a bland array of integers for each item selected, instead each item selected will be stored in the "item id" property of a new instance of the "order" CDT, which would also include other fields you'd like, including (but certainly not limited to) quantity.  Then, you'd simply invoke the CDT in your a!forEach() statement, and your "quantity" field (where it renders once for each item selected) can simply save the quantity entered into that property of the relevant entry in the array of Order (cdt) items.

    Also: when inserting long code like that, please use the "code box" functionality, which saves on post/comment length bloat, as well as preserving indentation/formatting.  Note: you can also edit your original post, if you feel like it, to present your original code in this way, which would make it more easily readable by subsequent readers of this thread.

Reply
  • 0
    Certified Lead Developer

    You should consider making your "order" a CDT object, so that instead of just populating a bland array of integers for each item selected, instead each item selected will be stored in the "item id" property of a new instance of the "order" CDT, which would also include other fields you'd like, including (but certainly not limited to) quantity.  Then, you'd simply invoke the CDT in your a!forEach() statement, and your "quantity" field (where it renders once for each item selected) can simply save the quantity entered into that property of the relevant entry in the array of Order (cdt) items.

    Also: when inserting long code like that, please use the "code box" functionality, which saves on post/comment length bloat, as well as preserving indentation/formatting.  Note: you can also edit your original post, if you feel like it, to present your original code in this way, which would make it more easily readable by subsequent readers of this thread.

Children