Try this in saveInto for the button:
a!forEach(
items: local!selectedIndices,
expression: a!save(
ri!clients[fv!item].clientID,
index(
local!selectedClients,
fv!index,
"clientID",
null
)
)
)
If you want, you can try it out my code in a sample interface:
a!localVariables(
local!selectedClients,
local!items: cast(
'type!{urn:com:appian:types:TS}Test_Clients?list',
{
{
id: 1,
name: "Test1",
mobile: 123,
clientID: 10
},
{
id: 2,
name: "Test2",
mobile: 456,
clientID: 20
},
{
id: 3,
name: "Test3",
mobile: 789,
clientID: 30
},
{
id: 4,
name: "Test4",
mobile: 1234,
clientID: 40
},
{
id: 5,
name: "Test5",
mobile: 12345,
clientID: 50
}
}
),
local!selectedIndices: tointeger({}),
a!formLayout(
contents: {
a!buttonArrayLayout(
align: "START",
buttons: {
a!buttonWidget(
label: "Update Local!",
value: "Update",
saveInto: {
a!save(
local!selectedClients,
index(local!items, local!selectedIndices, null)
)
},
disabled: count(local!selectedIndices) = 0
),
a!buttonWidget(
label: "Update ri!",
value: "Update",
saveInto: {
a!forEach(
items: local!selectedIndices,
expression: a!save(
ri!clients[fv!item].clientID,
index(
local!selectedClients,
fv!index,
"clientID",
null
)
)
)
},
disabled: count(local!selectedIndices) = 0
)
}
),
a!gridLayout(
headerCells: {
a!gridLayoutHeaderCell(label: "ID", align: "RIGHT"),
a!gridLayoutHeaderCell(label: "Name"),
a!gridLayoutHeaderCell(label: "Mobile", align: "RIGHT"),
a!gridLayoutHeaderCell(label: "Client ID", align: "RIGHT")
},
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3)
},
rows: a!forEach(
items: local!items,
expression: {
a!gridRowLayout(
id: fv!index,
contents: {
a!integerField(
value: fv!item.id,
readOnly: true,
align: "RIGHT"
),
a!textField(value: fv!item.name, readOnly: true),
a!integerField(
value: fv!item.mobile,
readOnly: true,
align: "RIGHT"
),
a!integerField(
value: fv!item.clientID,
readOnly: true,
align: "RIGHT"
)
}
)
}
),
selectable: true,
selectionValue: local!selectedIndices,
/* Flatten the selected values so the result is easier to work with */
/* when the select/deselect all option is used in an editable grid */
selectionSaveInto: a!save(
local!selectedIndices,
a!flatten(save!value)
),
rowHeader: 2
),
a!textField(
label: "Selected Values",
labelPosition: "ADJACENT",
instructions: typename(typeof(local!selectedIndices)),
value: local!selectedIndices,
readOnly: true
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(label: "Submit", submit: true)
)
)
)
Test ri! default value:
{
{
id: null,
name: "Test",
mobile: 1234567890,
ClientID: null
},
{
id: null,
name: "Test2",
mobile: 1234567893,
ClientID: null
},
{
id: null,
name: "Test3",
mobile: 1234567895,
ClientID: null
},
{
id: null,
name: "Test4",
mobile: 1234567898,
ClientID: null
},
{
id: null,
name: "Test5",
mobile: 1234567899,
ClientID: null
}
}