Skip to main content
May 17, 2023
Question

validate if entered string is in array of string

  • May 17, 2023
  • 4 replies
  • 0 views

Hello i am trying to make validation for editable grid in appian so i am not able to enter same value into multiple rows but even when value is entered only in one row validation is triggered. Here is the code for validation:

validations: if(
fv!item.value = local!arrayOfStrings,
"Id already exist",
""
),

fv!item.value is always there at least once as it is automatically stored in local!arrayOfString so even if it is not in local variable once i entered the value into grid it is saved into  array so i need to check if it is there more than once

thanks for any advice in advance

    4 replies

    mathieud0001
    Brainy
    May 17, 2023

    Unless I misunderstood, I believe this is covered here: community.appian.com/.../duplicate-string-in-the-string-array

    achutaharshavardhanv6069
    May 18, 2023

    may be you can do a small change 

    in your instead of local!arrayOfStrings do it like remove(local!arrayOfStrings,fv!index) and then do a condition like if(contains(remove(local!arrayOfStrings,fv!index),fv!item.value),"ID already exist","")

    May 18, 2023

    Perhaps you can make a little adjustment.

    #papa's freezeria

    sunilc6392
    May 18, 2023

    Hi Juraj,

    I think you should try this once, maybe it's work

    if(
                      count(
                        wherecontains(
                          tostring(index(fv!item, "value", {})),
                          touniformstring(
                            local!ArrayOfStrings
                          )
                        )
                      ) > 1,
                      "Id already exist",
                      null
                    )