Validation Rule Issue

Hi,

I need to apply one validation rule in inline editable grid with respective to each column. Like if we enter any value in first column than it should not be available in that particular column. This rule i am applying in with ->a!gridRowLayout

But when i am applying this it is showing red color from top to bottom to that particular text field.

 

1. I don't want to highlight whole column , it should highlight only particular cell only.

2. After changing field value validation rule is not refreshing.

Code which i added below.

validation{

  if(wherecontains(ri!testData[ri!index].nameCell,ri!testData.nameCell),"Duplicate",null)

}

 

Do i need to add something else to handle this issue ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi  one quick question here:

    1. Are you trying to execute this expression under forEach loop where each iteration calls gridRowLayout and this contains the textField which uses this expression for validation?

    If so, then may I know why ri!index  why not fv!index?

    2. Why wherecontains() because this returns array of indices, I believe you want to go for contains() where if array contains the given value then return "Duplicate" else {}

    E.g.

    if(contains(ri!testData.nameCell,ri!testData[fv!index].nameCell),"Duplicate",{})

    Also don't forget to have a null check or the type conversion otherwise when any one of the variable is null, you can expect an error saying: cannot compare null with Text

    Hope this helps.

Reply
  • 0
    Certified Lead Developer

    Hi  one quick question here:

    1. Are you trying to execute this expression under forEach loop where each iteration calls gridRowLayout and this contains the textField which uses this expression for validation?

    If so, then may I know why ri!index  why not fv!index?

    2. Why wherecontains() because this returns array of indices, I believe you want to go for contains() where if array contains the given value then return "Duplicate" else {}

    E.g.

    if(contains(ri!testData.nameCell,ri!testData[fv!index].nameCell),"Duplicate",{})

    Also don't forget to have a null check or the type conversion otherwise when any one of the variable is null, you can expect an error saying: cannot compare null with Text

    Hope this helps.

Children