The idea that I want to do is be able to save a specific answer into a specific spot into an array. I want to be able to select multiple drop downs save it into one array and then put that in the CDT to be referenced. I do not want to use a multiple dropdown because thats not in the scope of what I have to do nor is it plausible for the problem I have to complete. The basis of this interface is supposed to be able to click the add button add another option and then select if its the primary or not and then save those. This code you can play around with yourself:
a!localVariables( local!pubProd: {null}, local!dataProd1: {null}, local!count: 1, local!datacount: 1, { a!cardLayout( contents: { a!forEach( items: enumerate(local!count), expression: a!columnsLayout( columns: { a!columnLayout( contents: { a!dropdownField( label: "Producing Organization", labelPosition: "ABOVE", placeholder: "--- Select a Value ---", choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7", "Option 8", "Option 9", "Option 10", "Option 11", "Option 12"}, choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, value: local!pubProd[fv!index], saveInto: {local!pubProd[fv!index]}, searchDisplay: "AUTO", validations: {} ) }, ), a!columnLayout( contents: { a!checkboxField( label: "Primary", labelPosition: "ABOVE", choiceLabels: {""}, choiceValues: {true}, saveInto: {}, choiceLayout: "COMPACT", choiceStyle: "STANDARD", validations: {}, align: "CENTER" ) }, width: "EXTRA_NARROW" ) } ) ), a!columnsLayout( columns: { a!columnLayout( contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Remove", icon: "minus", value: local!count - 1, saveInto: local!count, size: "SMALL", style: "LINK" ) }, align: "END" ) }, width: "AUTO" ), a!columnLayout( contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Add", icon: "plus", value: local!count + 1, saveInto: local!count, size: "SMALL", width: "MINIMIZE", style: "LINK" ) }, align: "END", marginBelow: "STANDARD" ) }, width: "EXTRA_NARROW" ) } ), }, height: "AUTO", style: "NONE", marginBelow: "STANDARD" ), a!cardLayout( contents: { a!forEach( items: enumerate(local!datacount), expression: a!columnsLayout( columns: { a!columnLayout( contents: { a!dropdownField( label: "Data Producing Organization", labelPosition: "ABOVE", placeholder: "--- Select a Value ---", choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7", "Option 8", "Option 9", "Option 10", "Option 11", "Option 12"}, choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, value: local!dataProd1[fv!index], saveInto: {local!dataProd1[fv!index]}, searchDisplay: "AUTO", validations: {} ), } ), a!columnLayout( contents: { a!checkboxField( label: "Primary", labelPosition: "ABOVE", choiceLabels: {""}, choiceValues: {true}, saveInto: {}, choiceLayout: "COMPACT", choiceStyle: "STANDARD", validations: {}, align: "CENTER" ) }, width: "EXTRA_NARROW" ) } ) ), a!columnsLayout( columns: { a!columnLayout( contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Remove", icon: "minus", value: local!datacount - 1, saveInto: local!datacount, size: "SMALL", style: "LINK" ) }, align: "END" ) }, width: "AUTO" ), a!columnLayout( contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Add", icon: "plus", value: local!datacount + 1, saveInto: local!datacount, size: "SMALL", width: "MINIMIZE", style: "LINK" ) }, align: "END", marginBelow: "STANDARD" ) }, width: "EXTRA_NARROW" ) } ) }, height: "AUTO", style: "NONE", marginBelow: "STANDARD" ), } )
Discussion posts and replies are publicly visible
Have you tried using the a!update() function within saveInto? Here is the documentation link for it
https://docs.appian.com/suite/help/21.4/fnc_array_a_update.html
I am not too sure where I would put the a!update function. I tried putting it in the saveInto but that doesnt seem to work how I want it too.
Update:If I predefine it like this:
local!pubProd: repeat(4, null), local!dataProd1: repeat(4, null),
it works well except for the error I get which is:
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 9]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 16]: A dropdown component [label="Producing Organization"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was 1 and choiceValues was 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12.
Hi,
Try the updatearray() function to update the specific index value in an array,
updatearray() Function - Appian 21.4
updatearray( array, index, value ) for the index if you use the wherecontains() fn - which will help you to locate the index for the given value to update
How would you recommend I implement this?
The type of the choice values & the Value is different
typename(typeof(local!pubProd[1])) --> using this you can confirm the data types is different(use this for future findings)
the choice values - integer type (but)
local!dataProd1[fv!index] is returning text type
So cast() both choice values and the value as same datatype or in simple you can try this tointeger(local!dataProd1[fv!index])
You are a godsend thank you so much this worked perfectly. I dont think I ever connected that the problems was mismatching types