Main API Functions (Codeunit 10015822)
In this article
Checking Availability: GetAvailability()
Confirming Booking: ConfirmActivity()
Canceling Booking: CancelActivity()
Managing Additional Charges: SetAdditionalCharges()
Checking Availability: GetAvailability()
GetAvailabilityV4(LocationNo: Code[20]; ProductNo: Code[20]; ActivityDate: Date; ClientNo: Code[20]; OptionalResource: Code[20]; PromoCode: Code[20]; ActivityNo: Code[20]; NoOfPersons: Integer; CustomerAccountNo: Code[20]; var ErrorString: Text; var GetAvailabilityResponse: XmlPort "LSC ACT 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.
Promo code returns the promo code related pricing if applicable.
Activity No. can be used to refer to an existing activity/reservation to get related prices and restrictions.
No. of persons is for pricing purposes only.
Customer Account is for pricing purposes and also necessary if the installation is using allotments, to allow the availability call to include availability that is allotted to the specific customer.
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 is blank.
This request does not create a reservation in Business Centraland always returns availability at the request time.
Confirming Booking: ConfirmActivity()
ConfirmActivityV5(LocationNo: Code[20]; ProductNo: Code[20]; ActivityDate: Date; ActivityTime: Time; ClientNo: Code[20]; OptionalResource: Code[20]; OptionalComment: Text[200]; SetQuantity: Decimal; SetNoOfPeople: Decimal; Paid: Boolean; PromoCode: Code[20]; ClientName: Text[100]; Email: Text[200]; var ReturnActivityNo: Code[20]; var ErrorString: Text; var ReturnUnitPrice: Decimal; var ReturnLineDiscount: Decimal; var ReturnTotalAmount: Decimal; var ReturnCurrency: Code[20]; var ReturnBookingRef: Text[50]; var ReservationNo: Code[20]; var ReturnRetailItem: Code[20]; CustomerAccountNo: Code[20]; Token: Code[50]): Boolean
This function confirms a booking and creates an activity reservation. It returns True if the process created a booking and confirmed without errors. If failure, then no activity reservation is 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 is paid through the basket process. |
| Reservation No. | Optional reference to existing reservation. The activity is added to that reservation. If left blank then a new reservation is created or the activity is added to any existing reservation the client has active. |
| CustomerAccountNo | Optional for retrieving any special customer pricing. |
| Token | Optional reference to any prior reserved availability using token. If the token is still valid at booking time then this booking uses the allotment reserved by the token, otherwise availability is checked at confirmation. |
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 contains 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 at the customer order creation. |
| ReturnRetailItem | The posting item to be used for the related e-commerce customer order line. |
Canceling Booking: CancelActivity()
CancelActivity(ActivityNo : Code[20];ClientNo : Code[20];VAR
ErrorString : Text;VARReturnProductNo : Code[20];VAR
ReturnUnitPrice : Decimal;VARReturnQty : Decimal;VAR
ReturnLineDiscount : Decimal;VARReturnTotalAmount : Decimal;VAR
ReturnCurrency : Code[20];VARReturnBookingRef : 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 are 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).
SetAdditionalChargesV4(ReservationNo: Code[20]; 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.
- If the IsAllowance is set to True, then the charge will be processed as allowance. See online help on allowance handling for further information.
- Note: Charges to reservations (not activities) can be assigned by setting ActivityNo as blank.
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.