I have an array of maps that I iterate over and generate cards with links like so:
local!selectedCard, local!example: {a!map( icon: "first-aid", name: "name1", link: a!dynamicLink(saveInto: a!save(local!selectedCard, 1)) ), a!map( icon: "home", name: "name2", link: a!startProcessLink( processModel: some process, processParameters: { /* some params */ } ) ), /* some more options */ }, { a!columnsLayout( columns: { a!columnLayout(), a!forEach( items: local!options, expression: a!columnLayout( contents: { a!cardLayout( contents: { a!richTextDisplayField( labelPosition: "COLLAPSED", value: { char(10), char(10), a!richTextIcon( icon: fv!item.icon, color: "SECONDARY", size: "MEDIUM_PLUS" ), char(10), char(10), a!richTextItem( text: fv!item.name, color: "SECONDARY", size: "MEDIUM", style: "STRONG" ) }, align: "CENTER" ) }, link: fv!item.link, height: "SHORT_PLUS", shape: "ROUNDED" ) }, width: "MEDIUM" ) ), a!columnLayout() }, showWhen: a!isNullOrEmpty(local!selectedCard), marginBelow: "STANDARD" ) }
/* card link param */ link: if( fv!index = 2, a!startProcessLink( processModel: some_process_model, processParameters: { /* some params */ } ), a!dynamicLink(saveInto: a!save(local!selectedCard, fv!index)) )
However this way it is obvious if I (or someone else) in the future add an entry to the array the index specified might be wrong and the whole thing will break.
Discussion posts and replies are publicly visible
AFAIK this is one of the edge cases in SAIL. Trying to store a!save() in a local and make them evaluate as the user clicks, does not work.
But, you could work around this by storing the link target and link value separately and create the link and the a!save() inside the foreach. That's what I do in such situations.