Smart Buttons
Controls/XML Elements

If Then Else <ConditionalAction>

The <ConditionalAction> control (If Then Else) is the most basic flow statement. It tells a script to execute a certain section of code only if a particular test evaluates to true.

(If something is True, then do something; otherwise, do something else).

For example, you want to ask question on the screen to the agent: Do you want to add Cost Center?

  • If the agent selects Yes, a dialog box opens where the agent can enter the Cost Center. This Cost Center is added to the Booking File as a DI remark.

  • If the agent does not select Yes, the script ends.

Copy
<ButtonConf ButtonName="ConditionalAction test" Description="" QuickCommand="">
<CheckListBox Question="Do you want to add Cost Center?" Width="100" SelectDefaultAll="False" VarName="YesNo" SingleSelect="False" IsMandatory="True">
Yes;No
</CheckListBox>
<ConditionalAction Condition="YesNo==Yes">
<True>
<TextBox VarName="CostCenter" Question="Enter Cost Center" Width="25"></TextBox>
<RunCommand>DI.FT-Cost Center: [CostCenter]</RunCommand>
</True>
<False>
<Exit />
</False>
</ConditionalAction>
</ButtonConf>

Configuring

You can configure ConditionalAction using either the If Then Else XML Generator or XML.

Configuring with the If Then Else XML Generator

To configure with the If Then Else Editor:

  1. Open the Smart Buttons Editor to create a script.

  2. Click If Then Else <ConditionalAction>.

  3. Configure the attributes.

    Attribute

    Description

    Left argument/
    Right argument

    Enter the variable name or text that you want to make the check against. For example, in the example at the beginning of this chapter we wanted to check if the variable [YesNo] is equal to text: Yes ,so the left argument is variable [YesNo] and the right is text: Yes.

    You may want to leave one of the arguments blank. For example, you want to check if you have your PNR open, so you need to check if PNR number exist, so your right argument could be variable [CurrentPNRNr] and right argument could be empty (its means: if [CurrentPnrNr] variable is equal to empty…)

    The XML code would look like this: <ConditionalAction Condition="[CurrentPnrNr]==">

    Condition

    Click the arrow to the condition to apply to the arguments.

    Condition

    Description

    ==

    is equal to

    != is not equal to
    > is greater than
    < is less than
    >= is greater than or equal to
    <= is less than or equal to
    Set complex condition with OR and AND logical operator and groups Select to use complex conditions that includes OR or AND operators. More below.
    Condition is agreed Enter controls (XML elements) that you want to run when your condition is agreed (True). You may leave it empty, then if your condition is True, no action will be taken.
    Condition is not agreed Enter controls (XML elements) that you want to run when your condition is not agreed (False). You may leave it empty, then if your condition is False, no action will be taken.
  4. Click Submit.

Configuring with XML

To configure enter the following XML elements directly in the Travelport Smart Buttons editor.

Note: The grey <!-- elements are code comments, which can be deleted from the code if preferred.

Copy
<ConditionalAction Condition="">
<!-- for '>' sign use &gt; -->
<!-- for '<' sign use &lt; -->
<True>
<!--XML code to run when condition will resolve positive-->
</True>
<False>
<!--XML code to run when condition will NOT resolve positive-->
</False>
</ConditionalAction>
ConditionalAction

The only attribute used in the ConditionalAction XML element is Condition. For example in <ConditionalAction Condition="[ABC]!=6">, the Condition value is: [ABC]!=6 is:

  • [ABC] is the variable name

  • != is the condition (not equal to)

  • 6 is the value being compared

Condition Values

Condition or
Possible Conditions

Description

Example

== Is equal to <ConditionalAction Condition="RecordLocator==">
!= is not equal to <ConditionalAction Condition="CurrentPCC!=73XV">
&gt; is greater than

<ConditionalAction Condition="NumberOfTickets&gt;=1">

Note: Greater Than > and Less Than < symbols are not accepted in XML, so &gt and &lt are used in their place.

&lt; is less than <ConditionalAction Condition="PaxAge&lt;16">
&gt;= is greater than or equal to <ConditionalAction Condition="TicketPrice&gt;=6000">
&lt;= is less than or equal to <ConditionalAction Condition="CustomerBalance&lt;=450">
Complex Conditions

You can set complex conditions with OR and AND logical operators and groups.

The <ConditionalAction> elements allows you to make a logical comparison between a variable and the expected result by testing for a condition and returning a result if that condition is True or False.

However, if may need to test multiple conditions, where either:

  • All conditions must be True or False (AND)

  • Only one condition needs to be True or False (OR)

In these situations, you can add many conditions in one <ConditionalAction> element and combine them with OR and AND operators.

  • OR operator
    The conditional logical OR operator, computes the logical OR of its operands. The result of x OR y is true if either x or y evaluates to True. Otherwise, the result is False.

  • AND operator
    The conditional logical AND operator, computes the logical AND of its operands. The result of x AND y is true if both x and y evaluate to True. Otherwise, the result is False.

For example, you check can if the active PCC is 73XV or 5L4C.

Grouping Conditions

Use parentheses () to change the order of evaluation imposed by operator precedence.

For example, you can check if:

  • The active PCC is one of these three PCCs: 73XV,5L4C,XYZ

  • [RecordLocator] is not empty

The same sets of variables can give different script results either with or without parentheses.

For example, we can create two scripts that both meet the following three conditions:

  • If variable MNO is equal to 1 (False)

  • If variable ABC is equal to 1 (True)

  • If variable XYZ is equal to 2 (True)

For both scripts, if the Condition is:

  • True, the message True is displayed.

  • False, the message False is displayed.

The only difference between Script 1 and Script 2 are the addition of parentheses in Script 2, which groups the condition.

Script 1: No grouping (parentheses)

<ConditionalAction Condition="[MNO]==1 AND [ABC]==1 OR [XYZ]==2">

Result

Script 2: Grouping (Parentheses)

<ConditionalAction Condition="[MNO]==1 AND ([ABC]==1 OR [XYZ]==2)">

Result

Examples for <ConditionalAction>
Example 1

If a PNR/Booking File must be open for the script to work correctly, you can add a piece of code to the script that checks if the PNR/Booking File is open.

The following script displays the message Open PNR first, if no active Record Locator is found. (Condition="PNRRecordLocator ==" -Variable PNRRecordLocator is equal to null)

Copy
<ButtonConf ButtonName="test 30" Description="" QuickCommand="">
<Variable   VarName="PNRRecordLocator">%RecordLocator%</Variable>
<ConditionalAction Condition="PNRRecordLocator ==">
<True>
<ShowMessage>Open PNR first</ShowMessage>
</True>
</ConditionalAction>
</ButtonConf>
Example 2

If an option to rebook is offered after making a Fare Quote Best Buy (FQBB), display the message: YOU CAN REBOOK YOUR PNR.

If rebooking is not offered, add a Notepad remark: NO REBOOK FOUND.