Solved

Help with creatich expression

  • 14 August 2023
  • 3 replies
  • 44 views

Userlevel 1
Badge +1

I want to make a workflow for mails recieved between Saturday 20:00 to Monday 05:00.

For the saturday i try this: 

if(weekday({{ticket.created_at}}) == 7 and substring({{ticket.created_at}},11,13) > 20) 

But i keep getting "invalid operator” errors. als i cant seem to find a list of what format the value of the placeholders (like {{ticket.created_at}}) are.

Can someone help me on how i can do this? 

 

icon

Best answer by DirkH 14 August 2023, 16:07

View original

3 replies

Userlevel 7
Badge +13

Hello, 

You can look here for how placeholders will look like https://api.freshservice.com/v2/#create_ticket

But you need to use this {{ticket.created_at_iso}} to get the correct format. 

You need to do something like this. you was missing som ‘ 
This is set to Boolean as output. 

if(weekday('{{ticket.created_at_iso}}') == 7 && substring('{{ticket.created_at_iso}}',11,13) > '20',true,false)



weekday('{{ticket.created_at_iso}}') == 7 && substring('{{ticket.created_at_iso}}',11,13) > '20'

Both of them works, 

 

Userlevel 1
Badge +1

Thanks for the quick answer. apparently the weekday's where still of (Saturday is 0 and not 7 as the explanation in the expression builders says) but I managed to do what I wanted with this: 

(((weekday('{{ticket.created_at_iso}}') == 0 && substring('{{ticket.created_at_iso}}',11,13) > '19'))|| (weekday('{{ticket.created_at_iso}}') == 1)|| ((weekday('{{ticket.created_at_iso}}') == 2 && substring('{{ticket.created_at_iso}}',11,13) < '05')))

 

Userlevel 7
Badge +13

Thanks for the quick answer. apparently the weekday's where still of (Saturday is 0 and not 7 as the explanation in the expression builders says) but I managed to do what I wanted with this: 

(((weekday('{{ticket.created_at_iso}}') == 0 && substring('{{ticket.created_at_iso}}',11,13) > '19'))|| (weekday('{{ticket.created_at_iso}}') == 1)|| ((weekday('{{ticket.created_at_iso}}') == 2 && substring('{{ticket.created_at_iso}}',11,13) < '05')))

 

Nice, ya sometimes we need to do some trial and error. Don’t forget to mark this as solved. 

Reply