Service Catalog - if Statement for a text variable that contains "string"

Chase Stevenson
Mega Guru

I have a workflow set up for a catalog item and I want to include an IF Statement in the workflow that will check whether a single text field contains/starts with the following strings: "10.", "161.", "172."

To summarize, the script is supposed to check if the entered IP address in the variable begins with a 10. or a 161. or a 172. address.

Variable Name: source_ip

I tried scripting it out but I have no idea where to start as I want it to specifically check that the string BEGINS with the above numbers. I cannot use a CONTAINS condition because an IP of x.x.10.x would still trigger the statement.

Here's a picture of the proposed script that I've wrote up, can anybody provide any recommendations?

find_real_file.png

1 ACCEPTED SOLUTION

What type is the "source_ip" catalog variable?

You can force your script variable "sourceIP" to a string with the following:

var sourceIP = current.variables.source_ip.toString();

 

View solution in original post

10 REPLIES 10

OK, that's good.  I would have thought the single-line text would come over as a string as well, but it's best to always force it to whatever you need.