Hi all
I'm facing a problem when I try run this code:
a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: { hour(ri!ES_Working_Hours_Record.LeavingTime - ri!ES_Working_Hours_Record.StartTime), " hours", if( hour(ri!ES_Working_Hours_Record.LeavingTime - ri!ES_Working_Hours_Record.StartTime) = "8",
" Working hours are complete", if( and(8 > hour(ri!ES_Working_Hours_Record.LeavingTime - ri!ES_Working_Hours_Record.StartTime) > 0), " Working hours are not complete", if( hour(ri!ES_Working_Hours_Record.LeavingTime - ri!ES_Working_Hours_Record.StartTime) = 0, " insert working hours correctly please", " working hours passed limit" ) ) ) }, size: "STANDARD", style: { "STRONG" } ) } ) },
I got this message: Error Evaluating UI Expression Expression evaluation error [evaluation ID = ] in rule 'es_working_hours_record2' at function 'hour' [line 33]: A null parameter has been passed.
I need to make it null, because I want the user who inserts these values, so I think it should be Null.
Discussion posts and replies are publicly visible
In that case, just add a null check. First check in an if() condition that the value you have passed in hour() function is null or not. If null, then don't call the hour() function but if it is not null, then call it.
if( a!isnullOrEmpty(ri!value), null, hour(ri!value) )
Thanks for the answer
I've added the null check, but I got this: Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function 'hour' [line 36]: Could not cast from ES_Working_Hours_Record to Time. Details: CastInvalidCould not cast from ES_Working_Hours_Record to Time. Details: CastInvalid
Please add casting function todatetime() whenever you are referring to ES_Working_Hours_Record date time field
From the error is looks like that the whole CDT is passed in hour function instead of the field: LeavingTime or StartTime. Can you check that once? It's also a good practice to use casting so that the issue never comes up even if the field is of datetime type.
You mean like this: if( a!isnullOrEmpty(todatetime(ri!ES_Working_Hours_Record)), null, hour(todatetime(ri!ES_Working_Hours_Record)) ), hour(ri!ES_Working_Hours_Record.LeavingTime - ri!ES_Working_Hours_Record.StartTime), " hours", ?
define casting on top of hour() function, not outside of it