If (String)

Name

If (String)

Syntax

If (Boolean condition, String thenValue, String elseValue)

Purpose

To evaluate a given condition and if true, return result of thenValue. Otherwise, to return the result of elseValue.

Description

Returns the value of ‘Then’ expression or ‘Else’ expression depending on the value of condition.

Return Type

String

Parameters

Condition [System.Boolean] – Condition that is evaluated

thenValue [System.String] – This Parameter’s value is returned if the result of ‘condition’ parameter is true.

elseValue [System.String] - This Parameter’s value is returned if the result of ‘condition’ parameter is false.

Example

We have a Customers dataset which we will use to evaluate and transform the Items field.

In this example we will use the Expression object to define the condition, and a Variables object to define a string thenValue and a string elseValue.

Where,

Condition: Items = “1”

thenValue = FirstItem

elseValue ­ = SecondItem

In the output, you can see that string values, FirstItem and SecondItem, have been returned depending on whether the Items field condition was met.

© Copyright 2023, Astera Software