Hi Everyone,
I am new to apian and I am bit stuck on logic for validating grid records on save button. Heres my scenario I have been working with- I have grid with 5 columns, first 2 columns are read-only as the user entered data will be seeing on this form in my process model, 3rd column is where user has to enter the values if the 4th column is unchecked. 5th column is mandatory when 4th column check box is true.
I want to save records when either column 3 is filled or save when column 4 is checked and column 5 is filled. the below code isn't working
validations: if( and( count(local!items) = length(local!items.column1), count(local!items) = length(local!items.column2), or( count(local!items) = length(local!items.column3), and( count(local!items) = count(local!items.column4 = true), count(local!items) = length(local!items.column5), length(local!items.column3) = 0 ) ), ), "", "Please ensure you have entered Address Book Number or checked Exclude with comment" ),
Thanks in advance!
Discussion posts and replies are publicly visible
Hi Larisa ,
I have coded with the help of this statement - 'I want to save records when either column 3 is filled or save when column 4 is checked and column 5 is filled'.
Try the below code and let me know if it's working
if(
or(
and(a!isNotNullOrEmpty(column3), a!isNullOrEmpty(column4)),
and(a!isNotNullOrEmpty(column4), a!isNotNullOrEmpty(column5))
),
null(),
"Please ensure you have entered Address Book Number or checked Exclude with comment"
)
Why don't you use validation on grid itself instead on button(Complicated logic),we can simply use fv!item
validations: a!foreach( items:local!items, expression: if( fv!item.column4, if(isnullorempty(fv!item.column5),"Your message",""), if(isnullorempty(fv!item.column3),"Your message","")) )
or on grid column itself
/On third column validation/ if(fv!row.column4,"","Your message") /On fifth column validation/ if(fv!row.column4,"Your message","")