Skip to main content

I’ve got a service request that takes in a date and time field, then using an expression in a workflow, diffinhour(now(timezone), *Custom field from service request*), I determine if that time is in the future or the past. 
 

Testing the expression in the workflow editor worked great, but once I submitted a ticket, it failed with an invalid operand. It appears that the custom date and time field does not report in the correct format for the functions in expression builder? 

Has anybody experienced something similar? Is there a known workaround? 

I’ve got a service request that takes in a date and time field, then using an expression in a workflow, diffinhour(now(timezone), *Custom field from service request*), I determine if that time is in the future or the past. 
 

Testing the expression in the workflow editor worked great, but once I submitted a ticket, it failed with an invalid operand. It appears that the custom date and time field does not report in the correct format for the functions in expression builder? 

Has anybody experienced something similar? Is there a known workaround? 

You can use it like this  diffInHours({{current_date_and_time_iso}},{{ticket.created_at_iso}})

Change the second placeholder to the on in your service item. 

You need to use the _iso version of the placeholder else it will give you USA standard date. 

 

 

Check the execution logs for the workflow as it will show expressions. 


I’ve got a service request that takes in a date and time field, then using an expression in a workflow, diffinhour(now(timezone), *Custom field from service request*), I determine if that time is in the future or the past. 
 

Testing the expression in the workflow editor worked great, but once I submitted a ticket, it failed with an invalid operand. It appears that the custom date and time field does not report in the correct format for the functions in expression builder? 

Has anybody experienced something similar? Is there a known workaround? 

You can use it like this  diffInHours({{current_date_and_time_iso}},{{ticket.created_at_iso}})

Change the second placeholder to the on in your service item. 

You need to use the _iso version of the placeholder else it will give you USA standard date. 

 

 

Check the execution logs for the workflow as it will show expressions. 

Thank you! 

Adding the _iso has made that node work! 

Following this expression I have a conditional expression node thats simply {{e1.result}} > = 1 and determines what to do after that. 

This keeps returning “One of its operands is invalid.” despite the return value of the expressions builder being a number. The node details is “395>=1 - boolean”, so I don’t understand why its invalid


I’ve got a service request that takes in a date and time field, then using an expression in a workflow, diffinhour(now(timezone), *Custom field from service request*), I determine if that time is in the future or the past. 
 

Testing the expression in the workflow editor worked great, but once I submitted a ticket, it failed with an invalid operand. It appears that the custom date and time field does not report in the correct format for the functions in expression builder? 

Has anybody experienced something similar? Is there a known workaround? 

You can use it like this  diffInHours({{current_date_and_time_iso}},{{ticket.created_at_iso}})

Change the second placeholder to the on in your service item. 

You need to use the _iso version of the placeholder else it will give you USA standard date. 

 

 

Check the execution logs for the workflow as it will show expressions. 

Thank you! 

Adding the _iso has made that node work! 

Following this expression I have a conditional expression node thats simply {{e1.result}} > = 1 and determines what to do after that. 

This keeps returning “One of its operands is invalid.” despite the return value of the expressions builder being a number. The node details is “395>=1 - boolean”, so I don’t understand why its invalid

It could be due to the expression don’t see the placeholder as a number. 
Pressing save works and it works when it runs on a ticket ? 

You could do this in a conditional expression. 

 

if(diffInHours({{current_date_and_time_iso}},{{ticket.created_at_iso}}) >= 1,true,false)

or just

diffInHours({{current_date_and_time_iso}},{{ticket.created_at_iso}}) >= 1

conditional expression assumes that it’s if expression if nothing els is given.  

 

 


@Daniel Söderlund 

Just wanted to loop back and thank you again for your help. Your previous suggestion of putting everything in the conditional worked flawlessly for me. 


Yes, this is a common issue—custom date/time fields sometimes return values as strings instead of proper datetime objects. Try wrapping the custom field in a todate() function before using diffinhour(), like:
diffinhour(now(timezone), todate(custom_field)).
That usually resolves the operand error.


Reply