is it possible to break a forEach?
Discussion posts and replies are publicly visible
I have a for each to display a box for every item in my database, and inside each box I have a button that i press to get deatails of that particular item, i have a save into with a localVariable to get the Id of that particular item, but its storing all the Id's
Please post a code snippet.
a!localVariables( local!filtered: rule!AS_Get_By_Category(ri!filter), local!visivel, local!id, local!info: rule!AS_Get_By_Id(local!id), a!headerContentLayout( header: { a!billboardLayout( backgroundMedia: a!documentImage( document: cons!BILLBOARD ), backgroundColor: "#f0f0f0", marginBelow: "NONE", overlay: a!barOverlay( contents: { a!richTextDisplayField( label: "Appian Store", labelPosition: "COLLAPSED", value: { a!richTextHeader( text: { "Appian Store" }, size: "LARGE" ) }, align: "CENTER" ) } ) ) }, contents: { a!sectionLayout( label: "", labelSize: "MEDIUM", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!dropdownField( label: "Category", labelPosition: "ABOVE", placeholder: "--- What are you looking for? ---", choiceLabels: cons!AS_categories, choiceValues: cons!AS_categories, value: ri!filter, saveInto: ri!filter, searchDisplay: "AUTO", validations: {} ), a!forEach( items: local!filtered, expression: a!boxLayout( label: "", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!imageField( label: "Image", labelPosition: "COLLAPSED", images: { a!documentImage( document: fv!item.imageId ) }, size: "MEDIUM", isThumbnail: false, style: "STANDARD" ) } ), a!columnLayout( contents: { a!sideBySideLayout( items: { a!sideBySideItem( item: a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: { fv!item.name }, size: "MEDIUM_PLUS" ) } ) ), a!sideBySideItem( item: a!buttonArrayLayout( buttons: { a!buttonWidget( label: "details", icon: "info", saveInto: {a!save(local!visivel,true()), a!save(local!id,local!filtered.id) }, size: "LARGE", style: "NORMAL" ) }, align: "END" ) ) } ), a!sideBySideLayout( items: { a!sideBySideItem( item: a!richTextDisplayField( label: "Price", labelPosition: "ABOVE", value: { a!richTextItem( text: {"$" &fv!item.price} ) } ) ), a!sideBySideItem( item: a!richTextDisplayField( label: "Quantity", labelPosition: "ABOVE", value: { a!richTextItem( text: {fv!item.quantity} ) } ) ), a!sideBySideItem( item: a!buttonArrayLayout( buttons: { a!buttonWidget( label: "add to cart", icon: "shopping-cart", size: "LARGE", width: "MINIMIZE", style: "PRIMARY" ) }, align: "END" ) ) } ) }, width: "WIDE" ) } ) }, style: "#f3f3f3", marginBelow: "STANDARD" ) ) } ) } ) },showWhen: isnull(local!visivel) ), a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: { a!richTextIcon( icon: "long-arrow-left" ), " Back to the store" }, link: a!dynamicLink( value: null, saveInto: {a!save(local!visivel,null()), a!save(local!id,null())} ), linkstyle: "STANDALONE" ) }, showWhen: not(isnull(local!visivel)) ) } ) )
between line 97 and 105 iits where i try to save the id of the item
what this does is showing a part of the interface and hides the other, then if.i click details it will hide the items part of the interface and i want to show the item i pressed detailed information
Inside a foreach you have multiple variable in the fv-domain. One is fv!item which is the item from the list of the current iteration. So changing your button like this should help.
a!buttonWidget( label: "details", icon: "info", saveInto: { a!save(target: local!visivel, value: true()), a!save(target: local!id, value: fv!item.id) }, size: "LARGE", style: "NORMAL" )
BTW, it is considered a best practice to use keyword syntax.
https://docs.appian.com/suite/help/21.3/domain_prefixes.html
docs.appian.com/.../Expressions.html
It works, thank you