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) ) ) ) )
Best answer by zachary.king
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