Hi all,
I'm creating an interface that records and calculates the working hours for employees, the idea is if the working hours are less than 8 it should display: " Working hours are incomplete " , and if it was less than 0 it should display: " insert your working hours correctly please "
I made this expression, but when the value is less than 8 even it was less than 0 it always display : " Working hours are incomplete "
here's the expression:
{ a!richTextItem( if( ri!WorkingHours = "8", "Working hours are complete", if( 8 > ri!WorkingHours > 0, "Working hours are not complete", if( ri!WorkingHours < 0, "insert working hours correctly please" ) ) ) )
Discussion posts and replies are publicly visible
Using the amazing match function.
a!richTextDisplayField( value: { a!richTextItem( a!match( value: ri!WorkingHours, equals: 8, then: "Working Hours are complete", whenTrue: and(ri!WorkingHours > 0, 8 > ri!WorkingHours), then: "Working hours are not complete", default: "insert working hours correctly please" ) ) } )
it just show the default message even when the user inserts 8, or 4
workings hours as 8
working hours as 4
It is working fine for me. You must have misconfigured something. Can you add your code block for more understanding?
a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( a!match( value: ri!WorkingHours, equals: 8, then: "Working Hours are complete", whenTrue: and(ri!WorkingHours > 0, 8 > ri!WorkingHours), then: "Working hours are not complete", default: "insert working hours correctly please" ) ) } ),
This works fine for me. Did you populate ri!WorkingHours correctly?
yes I did.
I'm not sure why it would be doing that - can you confirm what data type your ri!WorkingHours is? If the value was somehow technically "greater than 8" (like perhaps in the back-end storing a value of 8.001 for example) then it would fail the condition. To troubleshoot, maybe try wrapping "ri!workingHours" in the "value" parameter of a!match() in "tointeger()", and see if that changes anything.
Additionally, the truly correct way of using a!match would be that you only invoke ri!workingHours once, then refer to it as fv!value within the "whenTrue" parameter, when needed. The difference may appear cosmetic, though this means that if you format the value parameter (such as using "tointeger()"), then further references to the value will remain consistent.