Conditional logic is used to alter service parameters based on specific conditions. This feature can be used to define the value of any parameter by any defined condition. It supports multiple 'If' and 'Else If' conditions. In conditional logic, a statement is only true if and only if a certain condition is fulfilled.

## Logic Block

A logic block is a block in which the condition logic is being defined. You can edit the block name by clicking on the Edit icon with a maximum 64-character limit.

Within the block, you can only add one ‘IF’ condition and one ‘ELSE’ condition but there can be multiple ‘ELSE IF’ conditions.

The ‘IF’ condition will come by default in every logic block which you cannot edit.

To every ‘IF’, ‘ELSE IF’, and ‘ELSE’ statement, there will be a ‘THEN’ statement.

Also, there can be multiple logic blocks.

In the Logic Block, you have to provide the following information:

- Select Parameter: In this field, you have to select the parameter to be used
- Data Type: In this field, you have to select the data type you want to use such as:
  - Numeric: This data type is used for numeric data like 23, 47, 536, etc.
    Relational operator options: = , != , > , < ,>= , <=< /li>
  - Decimal: This data type is used for decimal data like 23.34, 47.21, 536.65, etc.
    Relational operator options: = , != , > , < ,>= , <=
  - String: This data type is used for case-sensitive Strings like "Welcome" and "welcome" which have different meanings.
    Relational operator options: = , != , IN , NOT_IN , CONTAINS
  - String Ignore Case: This data type is used for case insensitive Strings like "welcome" and "Welcome" have the same meaning.
  - Relational operator options: = , != , IN , NOT_IN , CONTAINS
- Description of IN, NOT_IN, CONTAINS
  - IN: This relational operator can be applied to check if a given key is present in an object.
  - NOT_IN:This relational operator can be applied similarly to check if a key is not present in an object.
  - CONTAINS: This is used to search for a substring within a string or value.
- Select Parameter: In this field, you have to select the type of parameter against which you want to apply the condition.
- Add New Condition( ): This allows you to add a logical operator which is used to connect two or more phrases of information. Multiple conditions can also be applied using logical operators between them. The user can select any one of the following options:
  - AND: If the AND operator is used in-between two conditions, then the whole condition will be satisfied only when both conditions are satisfied.
  - OR: If the OR operator is used in-between two conditions, then the whole condition will be satisfied when any one of the conditions is satisfied.

To set parameters, click on the Set Parameter checkbox. To override service time, click on the Override Service Time checkbox. To log a message, click on the Log Message checkbox.

## Set Parameter

In the set parameter, you can choose an existing service parameter or you can add a new scratch parameter with the following options:

- Constant: In this option, you can provide a string or integer to overwrite selected parameters.
- Random Value from/To: In this option, you have to define the starting and ending of a random value.
- System Parameter: In this option, the system provides a dropdown that contains all system variables. System variables are pre-defined variables bundled with the Service Virtualization product.
- Service Parameter: In this option, the system provides a drop-down list that consists of already created parameters in the service.
- Random Value from List: In this option, you can define multiple values separated by “,”. The system takes any value randomly out of them.
- System Generated Unique Value: It will provide the unique value which is generated from the system.

## Override Service Time

To delay the actual service time, you have to enable the Override Service Time checkbox. It has the highest precedence for execution. Service time can be overwritten by the following options which are listed below:

- No Service Time: In this option, there will be no service time used.
- Exponential Random Service Time: For exponential random distribution, the median is roughly around ¼th of the mean. The service time is taken in milliseconds (ms).
- Constant Service Time: In this option, it will provide constant service time. The constant service time is taken in milliseconds (ms).
- Uniform Random Distribution: This option is used for uniform distribution service time. The random service time is taken in milliseconds.

## Log Message

In the log message, the message will be added in the Request Trace if Tracing is enabled. You can view these log messages in Request Trace UI under parameter and logs. In the log message, you have to provide the details for the following fields which are listed below:

- Message Name: In this field, you have to provide the name of the message.
- Message: In this field, you have to provide the message which is to be logged such as parameters. The message should be passed with the Curly{} For Example: {username}.

#### Notes:

1. For all the service parameters used if Occurrence Count = ALL, condition logic will consider the first occurring value.
2. Once the user has provided the inputs for the ‘Then’ statement, the user can either click over the ‘Add Statement ’ icon or can click on the 'Add Logic Block ' icon. Users can add multiple logic blocks as well.
3. If the user clicks over ‘Add Statement’ there will be only two options in the statement drop-down ‘Else if’ and ‘Else’.
4. Also there will be a ‘Delete Statement ’ icon for the ‘else if’ and ‘else’ statements.
5. Once the ‘ELSE’ statement is driven only ‘ELSE IF’ statements can be added in between IF and ELSE statements in a logical block.

- You can also perform the following operations in the conditional logic window which are listed below:
  - Import: If you want to import a predefined condition logic, you must click the import button. The file which you want to select should be in JSON format.
  - Export: If you want to export a condition logic, you must click the Export button. The file will be downloaded in the JSON format.
  - Delete: If you want to delete a preexisting logic block, then you have to click on the Delete
  - Reset: If you want to reset the condition logic window, then you have to click on the Reset Reset button. Once you click on the reset button it will display a confirmation window, click on the OK OK button if you want to reset. If you don’t want to reset, then click on the Cancel Cancel button.
  - Save: If you want to save a predefined condition logic, you must click the Save

{
"allBlocks": [
{
"blockName": "LOGICBLOCK1",
"logicBlock": [
{
"statement": "If",
"conditions": [
{
"lhsParam": "parameter name",
"paramType": 1,
"relationalOperator": 2,
"rhsType": 2,
"rhsParam": "Hello",
"logicalOperator": 1
}
],
"actions": [
{
“enabled”: true,
"paramName": "parameter name",
"rhsType": 1,
"rhsParam1": 4,
"rhsParam2": 5
},
{
“enabled”: true,
"logMessageName": "test",
"logMessageValue": "testingggg...."
},
{
“enabled”: true,
"serviceTimeMode": 2,
"serviceTimeValue1": 200,
"serviceTimeValue2": 400
}
]
},
]
}
]
}