The CreatorCon Call for Content is officially open! Get started here.

Work Flow Activity - Need to apply If Condition

komuru
Tera Contributor

I have a catalogue item for Which number of task should be created depending on the variable drop down.

For one 2 task should be created

For another one, 4 tasks should be created..

Now i have designed work flow where all Four task are created but i need only 2 tasks to be created when one variable is selected.

Please reply

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Karthik,



You can create the catalog task based on variable via run script activity. The sample code in the below blog. Adjust it accordingly.


Auto create Catalog Task based on Item Variables



Please let me know if you are blocked.


oharel
Kilo Sage

Hi Karthrik,


You can add a Branch activity to your workflow, then add conditions to it (right click on it and choose Add condition).


Give the condition a name and then in the condition, type current.variables.<VARIABLE_NAME> == 'VARIABLE OF CHOOSEN VALUE'


connect the conditions to the task creation activities.


See a sample screenshot below, where ,my variables are domain and email



find_real_file.png



and here is what the condition looks like:


find_real_file.png


harel


souren0071
Tera Expert

Hi,



You can use Branch, Switch, if any of these activities:



Create an If activity and paste the below code:


answer = ifVariable();


    function ifVariable() {


          if (current.variables.<variable name>== <value> ) {


                return 'yes';


          }


          return 'no';


    }




From Yes link it to 4tasks you have created and from No link it to 2 tasks among those 4 tasks. other 2 tasks will automatically be skipped.



Regards,


Souren