Working with an application called ServiceNow. It has a function
called Email Inbound Action. The Email Inbound Action has a single
If the statement evaluates True an incident is created.
If the statement does not evaluate True an incident is not created.
ServiceNow is getting an email from another appl called SolarWinds.
The servers in SolarWinds are marked PRODUCTION Y or
PRODUCTION N and send an email to ServiceNow with the PRODUCTION
attribute if the server goes down.
If PRODUCTION attribute in SolarWinds set to Y: in email body: "PRODUCTION_Y/N:Y": create incident.
If PRODUCTION attribute in SolarWinds set to N: in email body: "PRODUCTION_Y/N:N": do not create incident.
If PRODUCTION attribute in SolarWinds not set (null): in email body: "PRODUCTION_Y/N:": do not create incident.
I have got it to work for the first two cases with the condition
email.body_text.indexOf("PRODUCTION_Y/N:N") == -1
The fly in the ointment is if the PRODUCTION attribute is not set I get the
third case: "PRODUCTION_Y/N:":
If "PRODUCTION_Y/N:" ) comes in the email body the incident is created
which is incorrect.
(email.body_text.indexOf("PRODUCTION_Y/N:N") == -1 || email.body_text.indexOf("PRODUCTION_Y/N: ") == -1)
but this does not stop the unset attribute. I think because the second half of the OR statement is looking for a blank string when what is being returned is no text beyond the semicolon.
There are lots of ways using MATCH() or TEST() or REGEX() to check for strings but I
need to return a boolean false if a part of a string does not exist.
Allen in Dallas