Note: The scripts trigger pre-trip approval, and are associated with custom fields and queue delivery options. For an overview of setting up pre-trip approval, see "Setting Up Pre-Trip Approval" (under "Training Tips for Site Administrators" in the "Site Administrator Self-Directed Training" section of the Partner Dashboard Help content).
Pre-Trip Approval PNR Editor and Queue scripts
PNR Editor and Queue Delivery scrips related to PTA can be found here: Custom PNR Editor Script Samples for Pre-Trip Approval (PTA)
All Trips
The following use cases trigger pre-trip approval in all types of trips:
All Reservations
All reservations trigger pre-trip approval. This use case does not require a validating script.
International Reservations
All international reservations trigger pre-trip approval.
| | |
---|
PTA | International |
//INTERNATIONAL SEGMENT
var Int=UserPnrData.UserBooking.HasInternationalSegment;
if (Int=="Y") {out.print("true");}
else {out.print("false");}
|
One-way Reservations
All One-way reservations trigger pre-trip approval.
| Secondary tag/keywords | SCript |
---|
PTA | One-way |
//OneWay
var ifToPrint="false";
{var pta=UserPnrData.TravelType;
if (pta=="Oneway") {
ifToPrint="true";
}
out.print(ifToPrint);}
|
Offline Reservations
All reservations made offline trigger pre-trip approval.
| | |
---|
PTA | Offline |
//Offline
var Int=UserPnrData.TripOrigin;
if (Int!="web") {out.print("true");}
else {out.print("false");}
|
7 Day Advance Booking Required for Car, Hotel and Air segments
All reservations containing any car, air or hotel segment booked less than 7 days in advance trigger pre-trip approval
| | |
---|
PTA | Advance Booking |
// Script outputs "true" if any trip segments have been booked less than 7 days in advance of the segment start date.
// Segment start dates:
// Car rental - pickup date
// Flight - departure date
// Hotel - check-in date
var bookingDate = UserPnrData.UserBooking.AgencyTransactionDate
var segmentStartDates = [];
if (UserPnrData.UserBooking.CarBooking !== undefined &&
UserPnrData.UserBooking.CarBooking.Car !== undefined &&
UserPnrData.UserBooking.CarBooking.Car[0] !== undefined) {
segmentStartDates.push(UserPnrData.UserBooking.CarBooking.Car[0].PickupDate);
}
if (UserPnrData.UserBooking.AirBooking.FlightLeg !== undefined &&
UserPnrData.UserBooking.AirBooking.FlightLeg[0] !== undefined &&
UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment !== undefined &&
UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0] !== undefined) {
segmentStartDates.push(UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0].DepartureDate);
}
if (UserPnrData.UserBooking.HotelBooking !== undefined &&
UserPnrData.UserBooking.HotelBooking.Hotel !== undefined &&
UserPnrData.UserBooking.HotelBooking.Hotel[0] !== undefined &&
UserPnrData.UserBooking.HotelBooking.Hotel[0].Room !== undefined) {
segmentStartDates.push(UserPnrData.UserBooking.HotelBooking.Hotel[0].Room.CheckInDate);
}
var ifToPrint="false";
for (var i = 0; i < segmentStartDates.length; i++) {
if (segmentStartDates[i] == undefined) {
continue;
}
var segmentDate=new Date(segmentStartDates[i].Month + " " + segmentStartDates[i].Day + ", " + segmentStartDates[i].Year);
var bookingDate=new Date(bookingDate.Month + " " + bookingDate.Day + ", " + bookingDate.Year);
var days=0;
var difference=0;
difference=segmentDate-bookingDate;
days = difference/(1000*60*60*24);
if (days < 7) {
ifToPrint="true";
break;
}
}
out.print(ifToPrint);
|
Ticket Queue Delivery Block
This script is added to a Queue Delivery Option - Block itineraries that are triggered for pre-trip approval from passing to the normal ticketing queue (as they would if pre-trip approval was not enabled). This script allows itineraries that do not trigger pre-trip approval to pass to the normal ticketing queue as usual, but stops itineraries that trigger pre-trip approval from going to ticketing before they are approved.
| | |
---|
PTA | Ticket Queue |
var ifToPrint="true";
{var pta=UserPnrData.UserBooking.PreTripApprovalInfo.CurrentApprovalState;
if (pta=="WAITING_FOR_APPROVAL") {
ifToPrint="false";
}
out.print(ifToPrint);}
|
Pending/Waiting for Approval
This script is added to a Queue Delivery Option - Add this script to a queue delivery option if you'd like to drop on a queue PNRS which triggered the pre-trip approval process.
| | |
---|
PTA | Pending Approval |
var ifToPrint="false";
{var pta=UserPnrData.UserBooking.PreTripApprovalInfo.CurrentApprovalState;
if (pta=="WAITING_FOR_APPROVAL") {
ifToPrint="true";
}
out.print(ifToPrint);}
|
No Air Booked
All reservations without a flight trigger pre-trip approval.
| | |
---|
PTA | No Air Booked |
//No Air
var ifToPrint="false";
{var pta=UserPnrData.UserSession.AirSearch;
if (pta=="") {
ifToPrint="true";
}
out.print(ifToPrint);}
|
Flights
The following use cases trigger pre-trip approval for trips with flights:
Flight-Only Reservations
Reservations consisting of only flights trigger pre-trip approval.
| | |
---|
PTA | Air-only |
//Approval on Air Only Reservations
var display = "false";
var myFlightLeg=UserPnrData.UserBooking.AirBooking.FlightLeg;
var numLegs=myFlightLeg.length();
var i=0;
var j=0;
var myFlightSeg=UserPnrData.UserBooking.AirBooking.FlightLeg.FlightSegment;
for (i=0; i<numLegs; i++) {var numSegs=myFlightSeg[i].length();
for (j=0; j< numSegs; j++)
{with (UserPnrData.UserBooking.AirBooking.FlightLeg[i].FlightSegment[j])
{if (CarrierCode != "")
{display = "true";}
else {display = "false";}}}}
out.print (display);
|
Refundable Flight
Reservations consisting of only refundable flights trigger pre-trip approval.
| | |
---|
PTA | Air-only |
if (UserPnrData.UserBooking.AirBooking.AirFare.FareInfo.FareRules.Refundable=="true")
{out.print("true");}else
{out.print("false");}
|
Out of Policy Flights
All reservations with out-of-policy flights trigger pre-trip approval.
| | |
---|
PTA | OOP Air |
//Out of policy
var OOP=UserPnrData.UserSession.ComplianceCodes.AirCode;
if (OOP == undefined) {out.print("false");}
else {out.print("true");}
|
Flights Booked Within 14 Days of Departure
All reservations containing flights booked within 14 days of departure trigger pre-trip approval
| | |
---|
PTA | Advance Ticketing |
var ifToPrint="false";
var Month1=
UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0].DepartureDate.Month;
var Day1=
UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0].DepartureDate.Day;
var Year1=
UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0].DepartureDate.Year;
var Month2=UserPnrData.UserBooking.AgencyTransactionDate.Month;
var Day2=UserPnrData.UserBooking.AgencyTransactionDate.Day;
var Year2=UserPnrData.UserBooking.AgencyTransactionDate.Year;
var date1=new Date(Month1 + " " + Day1 + ", " + Year1);
var date2=new Date(Month2 + " " + Day2 + ", " + Year2);
var days=0;
var difference=0;
difference=date1-date2;
days = difference/(1000*60*60*24);
if((UserPnrData.UserBooking.AirBooking!=undefined)&&(days<14)){
ifToPrint="true";}
out.print(ifToPrint);
|
Air Ticket Cost
All reservations with flight tickets costing $600 or higher trigger pre-trip approval.
| | |
---|
PTA | Air ticket cost |
// Determine total cost of BOOKED FARE - supports split tickets
var BkdAirfare = UserPnrData.UserBooking.AirBooking.AirFare;
var numBkdFares = BkdAirfare.FareInfo.length && BkdAirfare.FareInfo.length();
if (numBkdFares > 0)
{ var bfTemp = parseFloat(0.0);
for (var i = 0; i < numBkdFares; i++)
{ bfTemp += parseFloat(BkdAirfare.FareInfo[i].TotalFare); }
var bf = bfTemp.toFixed(2); }
// Note TOTAL BOOKED FARE cap
if (bf>600.00)
{out.print("true");}else
{out.print("false");}
|
Specific Airlines
All reservations with one or more specific airlines trigger pre-trip approval. Airlines are defined in a list (for example, carrier code DL is defined in the script).
| | |
---|
PTA | Airline in list |
var display = "false";
var myFlightLeg=UserPnrData.UserBooking.AirBooking.FlightLeg;
var numLegs=myFlightLeg.length();
var i=0;
var j=0;
var myFlightSeg=UserPnrData.UserBooking.AirBooking.FlightLeg.FlightSegment;
for (i=0; i<numLegs; i++) {var numSegs=myFlightSeg[i].length();
for (j=0; j< numSegs; j++)
{with (UserPnrData.UserBooking.AirBooking.FlightLeg[i].FlightSegment[j])
{if (CarrierCode == "US")
{display = "true";}
else {display = "false";}}}}
out.print (display);
|
Class of Service
All reservations with a specific class of flight service (such as Coach shown in the script) trigger pre-trip approval.
| | |
---|
PTA | Class of Service |
//Class of Service
var ifToPrint = "false";
with (UserPnrData.UserBooking.AirBooking) {
for (var iFL=0; iFL<FlightLeg.length(); iFL++) {
for (var iFS=0;
iFS<FlightLeg[iFL].FlightSegment.length(); iFS++) {
if ((FlightLeg[iFL].FlightSegment[iFS].ServiceClass ==
"first") ||(FlightLeg[iFL].FlightSegment[iFS].ServiceClass ==
"business")){
ifToPrint = "true";
break;
}
}
}
}
out.print(ifToPrint);
|
Profile Field & Class of Service
Deem profile field has a certain value and the class of Services is: Business, Premium or First Class.
Tag/keyword | Secondary tag/ keyword | Script |
---|
PTA | Profile Field / Class of Service |
var sc;
var myFlightLeg=UserPnrData.UserBooking.AirBooking.FlightLeg; var numLegs=myFlightLeg.length(); var i=0; var j=0; var myFlightSeg=UserPnrData.UserBooking.AirBooking.FlightLeg.FlightSegment; for (i=0; i<numLegs; i++){ var numSegs=myFlightSeg[i].length(); for (j=0; j< numSegs; j++)
with (UserPnrData.UserBooking.AirBooking.FlightLeg[i].FlightSegment[j])
var sc=ServiceClass;
var dept=UserPnrData.User.UserInfo.DepartmentName;
var ifToPrint="false";
if((dept=="Staff")&&((sc=="business")||(sc=="first")||(sc=="premium coach"))){
ifToPrint="true";
}
out.print(ifToPrint);
break;}
|
Air Ticket Cost & Custom Field
All reservations with flights costing $500 or higher with a Custom Field on The Travel Planner Page
| | |
---|
PTA | Air ticket cost & Custom Field |
//TTL Airfare Booked & supports Split tkt
//To include trigger from **CFE** on Trip Planner Page
//replace (var app) with correct **CFE Custom Field Path**
var app=UserPnrData.CustomFields.ReportingFields.meetingPlanner;
var BkdAirfare = UserPnrData.UserBooking.AirBooking.AirFare;
var numBkdFares = BkdAirfare.FareInfo.length && BkdAirfare.FareInfo.length();
if (numBkdFares > 0)
{ var bfTemp = parseFloat(0.0);
for (var i = 0; i < numBkdFares; i++)
{ bfTemp += parseFloat(BkdAirfare.FareInfo[i].TotalFare); }
var bf = bfTemp.toFixed(2); }
// Note TOTAL BOOKED FARE cap is 500.00usd
if ((bf>500.00)&&(app=="John Smith"))
{out.print("true");}else
{out.print("false");}
|
Hotels
The following use cases trigger pre-trip approval for trips based on the hotel choice:
No Hotel
Any reservation without a hotel for overnight stay triggers pre-trip approval.
| | |
---|
PTA | No Hotel |
//NO HOTEL BOOKED
var display = "false";
if ((UserPnrData.UserBooking.HotelBooking == "")&&(UserPnrData.UserBooking.AirBooking != "")&&(UserPnrData.MeetingInfo.MeetingHeader.MeetingID == ""))
{
var myFlightLeg=UserPnrData.UserBooking.AirBooking.FlightLeg;
var numLegs=myFlightLeg.length();
var i=0;
var j=0;
var myFlightSeg;
var startDay = UserPnrData.UserBooking.AirBooking.FlightLeg[0].FlightSegment[0].DepartureDate.Day;
for (i=0; i<numLegs; i++) {
myFlightSeg=UserPnrData.UserBooking.AirBooking.FlightLeg[i].FlightSegment;
var numSegs=myFlightSeg.length();
for (j=0; j< numSegs; j++) {
with (UserPnrData.UserBooking.AirBooking.FlightLeg[i].FlightSegment[j]) {
if (startDay != DepartureDate.Day) {
display = "true";
}
else{
display = "false";
}
}
}
}
}
out.print (display);
|
Out of Policy Hotels
Any reservation with an out-of-policy hotel triggers pre-trip approval.
| | |
---|
PTA | OOP Hotel |
//Out of policy
var OOP=UserPnrData.UserSession.ComplianceCodes.HotelCode;
if (OOP == undefined) {out.print("false");}
else {out.print("true");}
|
Nightly Rate Hotels
Tag/keyword | Secondary tag/keywords | Script |
---|
PTA | Nightly Rate Hotel |
//Hotel Nightly Rate
var rate=UserPnrData.UserBooking.HotelBooking.Hotel[0].Room.NightlyRate;
if (rate>150.00)
{out.print("true");}else
{out.print("false");}
|
Car Rental
Any reservation with an out-of-policy car rental triggers pre-trip approval.
Out of policy Car
Total: Base + Taxes/Fees | | |
---|
PTA | OOP Car |
//Out of policy
var OOP=UserPnrData.UserSession.ComplianceCodes.CarCode;
if (OOP == undefined) {out.print("false");}
else {out.print("true");}
|
Train
Reservation containing Acela Train segment (based on class code = K).
| | |
---|
PTA | OOP Train/Rail |
//Rail ClassCode K (Acela)var ifToPrint = "false";
{
var myRailLeg=UserPnrData.UserBooking.RailBooking.RailLeg.RailSegment;
var numLegs=myRailLeg.length();
for (i=0; i<numLegs; i++)
with (UserPnrData.UserBooking.RailBooking.RailLeg.RailSegment[i])
{if (ClassCode=="K")
{ ifToPrint = "true";
break;
} } }
out.print(ifToPrint);
out.print(ifToPrint);
|