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
  • @saileshd- As suggested by kumaraveln, can you check whether ri!serialNumber in checkDuplicateSerialNumber expression rule is Text or Integer. If it is Integer and you are passing Text from the parent, it trims the text(aplhabets,special characters) and retains only the numerics. The trimmed number might be present in the DB and this might cause a problem.
    Please attach some screenshots of your test cases.

    @kumaraveln - If ri!serialNumber is Text in parent and Integer in the child rule, then it does not go in as null but the alphabets and special characters are trimmed. Attaching screenshots.
Reply
  • @saileshd- As suggested by kumaraveln, can you check whether ri!serialNumber in checkDuplicateSerialNumber expression rule is Text or Integer. If it is Integer and you are passing Text from the parent, it trims the text(aplhabets,special characters) and retains only the numerics. The trimmed number might be present in the DB and this might cause a problem.
    Please attach some screenshots of your test cases.

    @kumaraveln - If ri!serialNumber is Text in parent and Integer in the child rule, then it does not go in as null but the alphabets and special characters are trimmed. Attaching screenshots.
Children
No Data