Question regarding validation rules for textbox

Hi I am trying to make some validation rules for a textbox as follows:

a!textField(
label: "Serial Number",
value: ri!module.serialNumber,
saveInto: ri!module.serialNumber,
required: true,
validations: if(
rule!APN_isBlank(
ri!module.serialNumber
),
{},
if(
rule!ICAMS_checkDuplicateSerialNumber(
ri!module.serialNumber
),
"Serial Number Already Exists",
{}
)
)
/*validationGroup: "Duplicate"*/
)

The rule ICAMS_checkDuplicateSerialNumber() works perfect when tested out seperately and returns true() and false(), but its always true when used in an if loop as above. Does anyone has any idea why is it behaving that way?

OriginalPostID-212679

OriginalPostID-212679

  Discussion posts and replies are publicly visible

Parents
  • Try the below,
    1. As other practitioner told, map ri!module.serialNumber to instructions property to make sure the recent value is always passed to the validation rule. I am sure this would not be the issue but still to ensure.

    2. Check if the data type of ri!module.serialNumber and ri!serialNumber in child rule are same (in your case i guess its integer). If ri!serialNumber is Text or any other data type, it may go always as null because it cannot hold your integer value passed from parent rule. In that case if your dB has some rows with null values for serialNumber it always returns those rows and hence the rule returns true().
Reply
  • Try the below,
    1. As other practitioner told, map ri!module.serialNumber to instructions property to make sure the recent value is always passed to the validation rule. I am sure this would not be the issue but still to ensure.

    2. Check if the data type of ri!module.serialNumber and ri!serialNumber in child rule are same (in your case i guess its integer). If ri!serialNumber is Text or any other data type, it may go always as null because it cannot hold your integer value passed from parent rule. In that case if your dB has some rows with null values for serialNumber it always returns those rows and hence the rule returns true().
Children
No Data