Description

The EvalCaseGen Generator evaluates equations using up to 5 variables. When true, it returns the value of parameter caseTrue; otherwise, it returns the value of the parameter caseFalse. Parameters caseTrue and caseFalse may take a constant value or reference another Attribute. 


You can use the EvalCaseGen Generator to apply conditional logic at the Attribute level within a Domain. The equation defines the condition, and the output is determined by whether the equation is true or false. 


        If the equation (condition) is 'true'

            then Output A

        else Output B


Use Case Example: Check if a phone number is 'N/A'. If true, replace it with a default phone number, such as (123) 345-6789. Otherwise, keep the original phone number. Additional examples are provided later in this article. 


Note: You can only use one condition with this generator. For multiple conditions, please use the EvalCaseActionGen Generator. 


In This Article


Generator Parameters

The following parameters may be configured for the EvalCaseGen Generator. Items with an asterisk* are required. 

  • equation* - Contains the equation to be evaluated. 
  • var1 - The first of five possible variables to be used in the equation.
  • var2 - The second of five possible variables to be used in the equation.
  • var3 - The third of five possible variables to be used in the equation.
  • var4 - The fourth of five possible variables to be used in the equation.
  • var5 - The fifth of five possible variables to be used in the equation.
  • caseTrue* - Contains a constant value or reference to another Attribute when evaluation is true.
  • caseFalse* - Contains a constant value or reference to another Attribute when evaluation is false.


Note: 

  • While comparing strings, make sure to add double quotes around the variables in use, for example, "var1". 
  • If you are comparing numbers and the number is of type long, please append l (small case L), For example, var1l


What Operations are Allowed?

The allowable operations are:

  • &&, and
  • not, !
  • greater than or equal to (gte), >=
  • less than or equal to (lte), <=
  • div, /
  • mod, %
  • or, ||
  • equal, ==
  • not equal, !=
  • less than, <
  • greater than, >


Equation Examples

Example 1: var1 mod 2 == 0

Example 2: var1 < 5

Example 3: var1 > var2 && var2 < var3  

Example 1 - Generate First Names Based on Gender

The generated first name should match the individual's gender (male/female). Four linked generators are in this example (shown below).


GenderGen

Generates 'Male' or 'Female'


NameGen (Male)

Generates a male first name


NameGen (Female)

Generates a female first name


EvalCaseGen

var1 references the GenderGen, which will be used in the equation to determine if the value is 'Male'. If caseTrue, the output will be a male first name; otherwise, caseFalse and the output will be a female name.


The equation for checking the gender value is shown below.


Output

gen4 will generate the actual output, and other values are shown for reference.


Example 2 - Check Age to See If Individual Is Allowed to Vote

In this example, an age Attribute will generate a person's age, and an allowedToVote Attribute will generate the output based on the evaluated case. If the person is 18 and up, they should be allowed to vote and the Attribute value should be 'Yes'; otherwise, it should be 'No'.


Note: Two attributes have been used in this example to include both values in the generated output.  



age Attribute

Generates a random number between 10 and 65.


allowedToVote

Defines case to determine if the age is allowed to vote or not. The var1 parameter references the age Attribute. The equation uses the referenced value to determine if the number is 18 or above.


Sample Output


Example 3 - Check if a Number is Even or Odd

This example assigns a RandomGen and an EvalCaseGen to the Attribute. If the number is divisible by 2, it is even; otherwise, it is odd.



RandomGen

Generates random numbers ranging from 1 to 50



EvalCaseGen 

Determines if the referenced value is divisible by 2. If so, it is even; otherwise, it is odd. var1 references the value of RandomGen and is present in the equation: var1 % 2 == 0.


Sample Output


Example 4 - Check if a Number is Positive or Negative

This example uses a Domain with Linked Generators to show how to determine if a number is positive or negative. A RandomGen generates a random number between -50 and 50. The EvalCaseGen uses an equation to determine if the value is positive or negative.



RandomGen

Generates random numbers from -50 to 50


EvalCaseGen

Evaluates the number to determine if it is positive or negative.



Sample Output


Example 5 - Check if the Year is a Leap Year

For this example, the RangeGen Generator will be used to generate a four-digit number (representing a year) that starts at '2000' and increases by 1 for each row of data. The EvalCaseGen will reference the number and use an equation to check if it is a leap year. 


RangeGen

Generates a four-digit number starting with 2000 and increases by 1.



EvalCaseGen

The EvalCaseGen references the RangeGen for var1. If the value meets the case that is defined by the equation (true), the year is a leap year, and the output will be 'true'; otherwise, the output will be 'false".


The equation for this example is shown below:

(var1 % 4 == 0 && var1 % 100 != 0) || (var1 % 400 == 0))



Sample Output