Skip to main content
Solved

Is there a simple way to do if-elif-elif in an eval statement? Support 3 or 4 tests

  • March 11, 2025
  • 1 reply
  • 28 views

Support 3 or 4 tests

Best answer by David Maislin

There are a couple simple approaches using the Lookup Function or the Eval Function that should be easy to understand and maintain.

IN:

72_8ec02007743f4cf5a0d1e2a7e0c5fbd7.png


Example 1: The Lookup Function

Under Knowledge Lookups, create a Lookup Table

72_e0086396cac84feca06cc6c316cfcd00.png

Add a Lookup Function (Advanced Settings Ignore Case)

72_22234388e78047a89fd23da4726b6353.png


Example 2: The Eval Function

The syntax of /^IN$/i.test(direction) is a case insensitive (i) regular expression that tests for a match in the field direction. The ^ and $ represent the beginning and end of the value. The first line of the evan ensures that a direction field is not created if direction is not defined.

72_11a06b6c935a4495899179c873b5c2de.png

1 reply

David Maislin
  • Employee
  • Answer
  • March 11, 2025

There are a couple simple approaches using the Lookup Function or the Eval Function that should be easy to understand and maintain.

IN:

72_8ec02007743f4cf5a0d1e2a7e0c5fbd7.png


Example 1: The Lookup Function

Under Knowledge Lookups, create a Lookup Table

72_e0086396cac84feca06cc6c316cfcd00.png

Add a Lookup Function (Advanced Settings Ignore Case)

72_22234388e78047a89fd23da4726b6353.png


Example 2: The Eval Function

The syntax of /^IN$/i.test(direction) is a case insensitive (i) regular expression that tests for a match in the field direction. The ^ and $ represent the beginning and end of the value. The first line of the evan ensures that a direction field is not created if direction is not defined.

72_11a06b6c935a4495899179c873b5c2de.png