Hi All,
i have a grid to add master details, i want to have an validations to check on Duplicate values
please help me with the same, below is code i have written for grid and saving into CDT then passing it to Process model,
a!boxLayout( label: if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0), "Type", rule!LMP_getTypesListByFilters( typeid: ri!typeValueSelected ).description), contents: { a!gridLayout( label: "", headerCells: { a!gridLayoutHeaderCell( label: "Name" ), a!gridLayoutHeaderCell( label: "Active" ), a!gridLayoutHeaderCell( label: "" ), a!gridLayoutHeaderCell( label: "" ) }, columnConfigs: { a!gridLayoutColumnConfig(), a!gridLayoutColumnConfig( width: "ICON" ), a!gridLayoutColumnConfig( width: "ICON" ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: a!forEach( items: local!AllValuesMaster, expression: a!gridRowLayout( contents: { a!textField( value: fv!item.description, saveinto: fv!item.description, required: true ), a!checkboxField( label: "gbe-active", choiceLabels: { "" }, choiceValues: { true() }, value: if( or( isnull( fv!item.activein ), not( fv!item.activein ) ), null, toboolean( fv!item.activein ) ), saveInto: { a!save( fv!item.activein, if( isnull( save!value ), false(), save!value ) ) }, align: "CENTER" ), a!imageField( label: "delete " & fv!index, images: a!documentImage( document: a!iconIndicator( "MOVE_UP" ), altText: "Up", caption: "Move Up ", link: a!dynamicLink( value: fv!index, saveInto: { if( fv!index = 1, {}, { a!save( local!AllValuesMaster, insert( local!AllValuesMaster, fv!item, fv!index - 1 ) ), a!save( local!AllValuesMaster, remove( local!AllValuesMaster, fv!index + 1 ) ) } ) } ) ), size: "ICON" ), a!imageField( label: "delete " & fv!index, images: a!documentImage( document: a!iconIndicator( "MOVE_DOWN" ), altText: "Down", caption: "Move Down ", link: a!dynamicLink( value: fv!index, saveInto: { if( fv!index = count( local!AllValuesMaster ), {}, { a!save( local!AllValuesMaster, insert( local!AllValuesMaster, fv!item, fv!index + 2 ) ), a!save( local!AllValuesMaster, remove( local!AllValuesMaster, fv!index ) ) } ) } ) ), size: "ICON" ) } ) ), addRowLink: a!dynamicLink( label: "Add " & if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0), "Type", rule!LMP_getTypesListByFilters( typeid: ri!typeValueSelected ).description), saveInto: a!save( local!AllValuesMaster, append( local!AllValuesMaster, 'type!{urn:com:appian:types:LMP}LMP_REF_AllValues_VW'( activein: true(), typeid: ri!typeValueSelected ) ) ) ), shadeAlternateRows: true ), a!buttonLayout( primaryButtons: a!buttonWidget( label: "Submit", submit: true, value: cons!LMP_BUTTON_VALUES[5], saveInto: { if(ri!typeValueSelected = "1", a!save( ri!regionData, local!AllValuesMaster ),null), if(ri!typeValueSelected = "2", a!save( ri!sbgData, local!AllValuesMaster ),null), if(ri!typeValueSelected = "3", a!save( ri!sbuData, local!AllValuesMaster ),null), if(ri!typeValueSelected = "10", a!save( ri!functionData, local!AllValuesMaster ),null), if(ri!typeValueSelected = "17", a!save( ri!subRegionData, local!AllValuesMaster ),null), if(ri!typeValueSelected = "11", a!save( ri!countryData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "14", a!save( ri!bandData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "7", a!save( ri!ratingData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "15", a!save( ri!nineblockingData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "6", a!save( ri!jobfunctionData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "16", a!save( ri!programTemplateData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "13", a!save( ri!potentialratingData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "5", a!save( ri!ethnicityData, local!AllValuesMaster ) ,null), if(ri!typeValueSelected = "8", a!save( ri!demographicData, local!AllValuesMaster ) ,null), a!save( ri!buttonValue, "submit" ) } ), secondaryButtons: a!buttonWidget( label: "Cancel", style: "DESTRUCTIVE", submit: true, value: cons!LMP_BUTTON_VALUES[7], saveInto: {a!save( ri!buttonValue, "cancel" )}, skipValidation:true ) ) }, showWhen: contains(local!value, ri!typeValueSelected) )
Discussion posts and replies are publicly visible
Like, when writing data into database, its writes only the unique values, kind of write to Datastore only the distinct values
Either in your process model or in the SAIL form, you can easily at some point remove duplicate rows from your CDT by passing it through a rule that removes duplicate values - I always suggest you have a global utility expression rule in your environment where it takes an array as its one parameter, and then does union(ri!array, ri!array) within the rule. You could add this as an extra member of the saveInto parameter of the button that submits your form, or in a script task prior to the Write to Data Store node. Please note that for a CDT, this will only remove rows that are 100% duplicative of another row.
Sure Mike , will give it a Try, Thank you
Hi Mike, this dint work, as the others column have different data.
Well if other columns will contain different data, then I'd say the data isn't truly duplicate. It would probably be better to restrict duplication of the data on just this column within the form, as in my original example.
Tried that Mike, its showing duplicate data validation on all the columns of GRID, even if there is only one entry, because of which am not able to submit.