how can i make a condition for an if statement to be passed and evaluated at run time

carmelfranco
Kilo Contributor

i have an if condition, i need to evaluate this condition based on the condition selected by the user

 

if user chooses the condition  

A="Add" AND B="User Account" AND C="Remote", this condition needs to be passed to the if condition in the workflow and gets evaluated as  

if(current.variables.A=="Add" &&  current.variables.B=="User Account" && current.variables.C=="Remote")

 

if user chooses,  

(A="Add" OR A=="Modify") AND (B="User Account" OR B="windows account" ) AND (C="Remote" OR C="Local") , this condition needs to be passed to the if condition in the workflow and gets evaluated as  

if((current.variables.A=="Add" || current.variables.A=="Modify") && (current.variables.B=="User Account" || current.variables.B=="windows account")&& (current.variables.C=="Remote" || current.variables.C=="Local"))

5 REPLIES 5

Mwatkins
ServiceNow Employee
ServiceNow Employee

Assuming a Service Catalog workflow you can populate these variables through the UI by adding the Variables to the specific Catalog item. It looks like the values of the variable you want are a small predictable group of string values. This is probably best done through a Select Box variable. Once you have created the necessary variables for your Service Catalog they can be accessed through the If workflow activity. Use the Advanced checkbox to indicate that you want a scripted condition to be evaluated at runtime.



However, perhaps you are hoping to evaluate these conditions prior to the start of the workflow. In that case, let me look a little more.


Mwatkins
ServiceNow Employee
ServiceNow Employee

After looking at your conditions a little more I am confused. The second condition is a super set of the first condition.



A="Add" AND B="User Account" AND C="Remote"


(A="Add" OR A=="Modify") AND (B="User Account" OR B="windows account" ) AND (C="Remote" OR C="Local")



Can you clarify the question?


  1. Is this for the initial launch conditions of the workflow or something later?
  2. Also, why would you evaluate two conditions where one is a subset of the other?
  3. Finally, can you write out the full logical requirement with the intended results of each condition?

Hi Matthew,



this is how it should be evaluated at run time as the example provided above are completely different scenarios.


i agree they are subset of the scenario 1 but very important here is how i can make it evaluate at run time?



if you worked with other tools such as remedy, it has external qualification, where we can enter the qualification as a input from other table



hope this clarifies.



Thank you


You can add them as conditions in a filter, or as part of a script in a workflow... but I suppose the greater question is: what do you want to achieve?



If this is indeed the service catalogue, you may want to consider an Order Guide or a Record Producer that permits you to add business logic that changes offerings depending on earlier choices.