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.
<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:
-
Open the Smart Buttons Editor to create a script.
-
Click If Then Else <ConditionalAction>.
-
Configure the attributes.
-
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.
<ConditionalAction Condition="">
<!-- for '>' sign use > -->
<!-- for '<' sign use < -->
<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 |
Description |
Example |
---|---|---|
== | Is equal to | <ConditionalAction Condition="RecordLocator=="> |
!= | is not equal to | <ConditionalAction Condition="CurrentPCC!=73XV"> |
> | is greater than |
<ConditionalAction Condition="NumberOfTickets>=1"> Note: Greater Than > and Less Than < symbols are not accepted in XML, so > and < are used in their place. |
< | is less than | <ConditionalAction Condition="PaxAge<16"> |
>= | is greater than or equal to | <ConditionalAction Condition="TicketPrice>=6000"> |
<= | is less than or equal to | <ConditionalAction Condition="CustomerBalance<=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)
<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.