Main API Functions (Codeunit 10015822)
In this article
Checking Availability: GetAvailability()
Confirming Booking: ConfirmActivity()
Canceling Booking: CancelActivity()
Managing Additional Charges: SetAdditionalCharges()
Checking Availability: GetAvailability()
GetAvailability(LocationNo : Code[
20
];ProductNo :
Code[
20]
;ActivityDate : Date;ClientNo : Code[
20
];OptionalResource :
Code[
20
];
VAR
ErrorString : Text;
VAR
GetAvailabilityResponse :
XMLport "Activity Availability Response") : Boolean
This function returns an XML document with the availability options. The function returns True if availability was found, otherwise it returns False and an ErrorString. OptionalResource is left blank unless a specific resource is required.
XML Response
Node Name | Prefix | Node Type | Source Type | Data Source |
---|---|---|---|---|
AvailabilityWork | Element | Table | <Availability Worktable> | (Availability Worktable) |
ProductNo | Element | Field | Availability Worktable: | :No |
AvailDate | Element | Field | Availability Worktable: | :Availability Date |
WeekDay | Element | Field | Availability Worktable: | :Week Day |
AvailTime | Element | Field | Availability Worktable: | :Availability Time |
Availability | Element | Field | Availability Worktable: | :Availability |
TimeCaption | Element | Field | Availability Worktable: | :Time Caption |
Location | Element | Field | Availability Worktable: | :Location |
PriceElement | Element | Field | Availability Worktable: | :Price |
OptionalResourceNo | Element | Field | Availability Worktable: | :ResourceNo |
OptionalResourceName | Element | Text | OptionalResourceName | |
PriceCurrency | Element | Text | ShowCurrency |
This respond may include multiple days, multiple locations, and multiple resources, depending on the Business Central settings. If not returned per resource, then the optionalResourceNo element will be blank.
This request will not create a reservation in Business Centraland will always return availability at the request time.
Confirming Booking: ConfirmActivity()
ConfirmActivity(LocationNo : Code[
20
];ProductNo :
Code[
20
];ActivityDate : Date;ActivityTime : Time;ClientID :
Code[
20
];OptionalResource : Code[
20
];OptionalComment :
Text[
200
];SetQuantity : Decimal;SetNoOfPeople : Decimal;Paid :
Boolean;
VAR
ReturnActivityNo : Code[
20]
;
VAR
ErrorString : Text;
VAR
ReturnUnitPrice : Decimal;
VAR
ReturnLineDiscount : Decimal;
VAR
ReturnTotalAmount : Decimal;
VAR
ReturnCurrency : Code[
20
];
VAR
ReturnBookingRef : Text[
50
]) : Boolean
This function will confirm a booking and create an activity reservation. It returns True if the process created a booking and confirmed without errors. If failure, then no activity reservation will be created.
Optional values set in the front end
OptionalComment | Free text to be passed to the reservation. |
SetQuantity | Can be modified in front end depending on the product setting. |
SetNoOfPeople | The number of people (persons), can be set by front end depending on the product setting. |
Paid | If the booking will be paid through the basket process. |
Return values
ReturnActivityNo | The booking reference created in Business Central. Must be assigned on the basket entry and passed to Commerce as sales line Order Reference, if being paid using basket processes. |
ErrorString | If the reservation confirmation failed, this will contain the reason for failing. |
ReturnUnitPrice | The unit price to be passed to the retail basket. |
ReturnLineDiscount | The line discount percentage to be passed to the retail basket. |
ReturnTotalAmount | The total net amount to be passed to the retail basket. |
ReturnCurrency | The currency code of the amounts. |
ReturnBookingRef | Reference assignment to be passed to the Commerce transaction for payment validation. |
Canceling Booking: CancelActivity()
CancelActivity(ActivityNo : Code[
20
];ClientNo : Code[
20
];
VAR
ErrorString : Text;
VAR
ReturnProductNo : Code[
20
];
VAR
ReturnUnitPrice : Decimal;
VAR
ReturnQty : Decimal;
VAR
ReturnLineDiscount : Decimal;
VAR
ReturnTotalAmount : Decimal;
VAR
ReturnCurrency : Code[
20
];
VAR
ReturnBookingRef : Text[
50
]) : Boolean
This function cancels the activity and returns values to the retail basket, if the activity was already paid and needs to be refunded. Otherwise, return values will be zero. Cancellation policies may also affect the amounts returned.
An activity can only be canceled once, and the client number must be passed as well for security purposes.
Return amounts are only included if the activity was confirmed as Fully Paid through the Commerce process.
Managing Additional Charges: SetAdditionalCharges()
This function inserts, modifies, or deletes additional charges related to a specific Activity (Booking).
SetAdditionalChargesV3(ActivityNo: Code[20]; LineNo: Integer; ProductType: Option Item,Deal; ProductNo: Code[20]; Qty: Decimal; Price: Decimal; DiscountPercentage: Decimal; UnitOfMeasure: Code[20]; VariantCode: Code[20]; ParentLine: Integer; IsAllowance: Boolean; OptionalComment: Text[200]; var ErrorString: Text): Boolean
Note:
- If Line No. does not exist in current additional entries, the entry is inserted.
- If Line No. exists, the entry is modified.
- If Product No. is empty, and the Line No. exists, the line is deleted.
- Pricing is set by the API caller.
- If the ParentLine parameter is set, the value must refer to an existing additional charge line of the Product Type = "Deal". The entry is then considered a component line belonging to the deal, and is inserted as "Deal line" entry.
The entry goes through the same validation process as any modification done via the BackOffice pages, and the same restrictions and qualifications are applied as was done by manual input.
Note: Deal component lines are not applied automatically (as by manual input), but the API must provide all the deal component lines, both regarding pricing and quantities. Should also provide the deal "Parent" line, which must be of product type Deal, and should set the total deal price, which should be matching the total of the component deal lines.