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

  • 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.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Thanks for the approach, the approach seems clean.

    BTW I have already implemented it using local variables and multiple dropdowns. But your approach seems neat and clean, Will try to implement it.

  • 0
    Certified Lead Developer
    in reply to tanujd6440

    Cool - local variables should work as well - you could just build a local variable containing a list of map / dictionary items, with the properties i mentioned.  This is usually an easier way of starting out, since you don't need to decide on all elements of a novel CDT structure all at once - then after you're pretty confident what you need, you can migrate to a CDT (if you even need/want to).