a!dateField( label: "Return To Office Date", labelPosition: if(ri!readOnly, "ADJACENT", "ABOVE"), value: ri!NIC_LeaveSummary.returntoofficedate, saveInto: ri!NIC_LeaveSummary.returntoofficedate, readOnly: ri!isLeaveApplied, validations: { if(calworkdays(ri!NIC_LeaveSummary.leavestartdate,ri!NIC_LeaveSummary.returntoofficedate)- 1 >5,"You can apply max 5 days leaves",{}), if( a!isNotNullOrEmpty(ri!NIC_LeaveSummary.leavestartdate), if( calisworkday(ri!NIC_LeaveSummary.leavestartdate), {}, "Please select weekdays. Weekends are not allowed" ), {} ), if( a!isNullOrEmpty(ri!NIC_LeaveSummary.leavestartdate), "Please select leave start date", {} ), if( ri!NIC_LeaveSummary.leavestartdate > ri!NIC_LeaveSummary.returntoofficedate, " Please select return to office date later than leave start date", {} ), } ),
Discussion posts and replies are publicly visible
The error message is very clear. Do you have a specific question?
Hello kajalp8940,
Is this error when you have not yet interacted with the fields?
If yes then it is because you are passing null values to evaluate the calworkdays function. You will have to do a null check and then do the validations. You will have to write a condition in such a way that if the values are empty, it does not validate. only when your values that are being evaluated are not null the validation ,ust be done.
It is a good practice to use index() instead of dot notation and do the null checks.
if(or(a!isNullOrEmpty(ri!NIC_LeaveSummary.leavestartdate),a!isNullOrEmpty(ri!NIC_LeaveSummary.returntoofficedate)),{},if( calworkdays(ri!NIC_LeaveSummary.leavestartdate,ri!NIC_LeaveSummary.returntoofficedate) -1 > 5,"You can apply max 5 days leave",{})),
if(or(a!isNullOrEmpty(ri!NIC_LeaveSummary.leavestartdate),a!isNullOrEmpty(ri!NIC_LeaveSummary.returntoofficedate)),{}, if( calworkdays(ri!NIC_LeaveSummary.leavestartdate,ri!NIC_LeaveSummary.returntoofficedate) -1 > 5, "You can apply max 5 days leave",{})),
And a readable version ;-)
if( or( a!isNullOrEmpty(ri!NIC_LeaveSummary.leavestartdate), a!isNullOrEmpty(ri!NIC_LeaveSummary.returntoofficedate) ), {}, if( calworkdays(ri!NIC_LeaveSummary.leavestartdate, ri!NIC_LeaveSummary.returntoofficedate) -1 > 5, "You can apply max 5 days leave", {} ) ),