Solved

Nested IF expression

  • 26 August 2022
  • 1 reply
  • 50 views

Is it possible to write an expression with nested IF?
I want to extract a case number from the subject, but the sender sends emails with three different subjects.

My thought was to write a function that checks if the beginning of the subject is XXX, then it should extract in a way. If the subject starts with YYY instead, it must extract in a different way. And if the topic starts with ZZZ, it should extract in a third way.

Something like this:

if(startsWith('{{ticket.subject}}','XXX'),
substring('{{ticket.subject}}', indexOf('{{ticket.subject}}','XXX',0)+length('XXX '), indexOf('{{ticket.subject}}',',',indexOf('{{ticket.subject}}','XXX',0) ) ),
if(startsWith('{{ticket.subject}}','YYY'),
substring('{{ticket.subject}}', indexOf('{{ticket.subject}}','YYY',0)+length('YYY '), indexOf('{{ticket.subject}}',';',indexOf('{{ticket.subject}}','YYY',0) ) ),
substring('{{ticket.subject}}', indexOf('{{ticket.subject}}','ZZZ',0)+length('ZZZ '), indexOf('{{ticket.subject}}',':',indexOf('{{ticket.subject}}','ZZZ',0) ) )
)
)

 

icon

Best answer by zachary.king 29 August 2022, 15:31

View original

1 reply

Userlevel 7
Badge +14

Hello, @Jnstare it is completely possible to nest if statements using the functional expression node in workflow automator. 

Here is an example of one that we have used.

if('{{P3.root.SamAccountName}}' == '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '1'}}', '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '2'}}', if( '{{P3.root.SamAccountName}}' == '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '2' }}', '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '3' }}', if( '{{P3.root.SamAccountName}}' == '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '3'}}', '{{ticket.onboarding_request.actor_1.cf_first_name | truncate: '1', '' | append: ticket.onboarding_request.actor_1.cf_last_name | append: '4'}}', 'Error' ) ))

Hope that helps

Reply