I have to validate a editable grid for the following scenario -
I have two fields in the grid 1. Role 2. Location
use case - if the user select combination of same role and location as a duplicate then it should thrown an validation error like combination of role and location already exits.
example - if the user select role as developer and location as india and again he adding a new row and selecting the same role and same location it should throw an error
any one suggest some idea
Discussion posts and replies are publicly visible
Please try this.
a!localVariables( local!data, a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Role"), a!gridLayoutHeaderCell(label: "Location") }, addRowLink: a!dynamicLink( label: "Add", saveInto: { a!save( local!data, append(local!data, { role: "", loc: "" }) ) } ), rows: a!forEach( items: local!data, expression: a!gridRowLayout( contents: { a!dropdownField( choiceLabels: { "Dev", "Tester" }, choiceValues: { "Dev", "Tester" }, placeholder: "---", value: fv!item.role, saveInto: fv!item.role, validations: if( count( intersection( wherecontains( tostring(fv!item.role), a!flatten(local!data.role) ), wherecontains( tostring(fv!item.loc), a!flatten(local!data.loc) ) ) ) > 1, "combination of role and location already exits", "" ) ), a!dropdownField( choiceLabels: { "India", "USA", "AUS" }, choiceValues: { "India", "USA", "AUS" }, placeholder: "---", value: fv!item.loc, saveInto: fv!item.loc, validations: if( count( intersection( wherecontains( tostring(fv!item.role), a!flatten(local!data.role) ), wherecontains( tostring(fv!item.loc), a!flatten(local!data.loc) ) ) ) > 1, "combination of role and location already exits", "" ) ) } ) ) ) )
Thanks its worked