Extra Values
ExtraValues is a concept in Spider that makes it possible to extend Spider's Web Services and API, so fields/data that are not available "out-of-the-box" can be handled. For example, it can be used to support fields in a table extension. Use PTE event subscribers for full control on either surface, or, for API pages only, the Extra Value Field Mappings setup page to map fields without writing code.
Note
10 ExtraValues per service is supported, all of datatype Text.
Tip
The data length of each ExtraValue field is not limited by Spider. This makes it possible to, as an example, put json data inside a ExtraValue if the data is complex or if there's a need for more than 10 fields.
API Page Web Services
The following events are published for Web Services of type API Page:
| Event | Description |
|---|---|
| OnGetExtraValues | Use this event if you want to set ExtraValues that can be read by an external system. |
| OnAfterInsert | Use this event if you want to let the external system set values when the record is inserted. This event is only available in services that support insertion of records. |
| OnBeforeModify | Use this event if you want to let the external system set values when the record is modified. This event is only available in services that support modification of records. |
How to Use API Page Web Services
You have added a field called Bonus on the Customer record. An external system wants to read and modify this field. Then you can add two event subscribers to your PTE:
[EventSubscriber(ObjectType::Page, Page::"QWESR API - Customers", 'OnGetExtraValues', '', false, false)]
local procedure OnGetExtraValues(Customer: Record Customer; var ExtraValue1: Text; var ExtraValue2: Text; var ExtraValue3: Text; var ExtraValue4: Text; var ExtraValue5: Text; var ExtraValue6: Text; var ExtraValue7: Text; var ExtraValue8: Text; var ExtraValue9: Text; var ExtraValue10: Text)
begin
ExtraValue1 := Customer.Bonus;
end;
[EventSubscriber(ObjectType::Page, Page::"QWESR API - Customers", 'OnBeforeModify', '', false, false)]
local procedure OnBeforeModify(var Customer: Record "Customer"; ExtraValue1: Text; ExtraValue2: Text; ExtraValue3: Text; ExtraValue4: Text; ExtraValue5: Text; ExtraValue6: Text; ExtraValue7: Text; ExtraValue8: Text; ExtraValue9: Text; ExtraValue10: Text)
begin
Customer.Bonus := ExtraValue1;
end;
Page Web Services
The following events are published for Web Services of type Page:
| Event | Description |
|---|---|
| OnGetExtraValues | Use this event if you want to set ExtraValues that can be read by an external system. |
| OnModifyExtraValues | Use this event if you want to let the external system set values. This event is only available in services that support modification of records. |
How to Use Page Web Services
You have added a field called Bonus on the Customer record. An external system wants to read and modify this field. Then you can add two event subscribers to your PTE:
[EventSubscriber(ObjectType::Page, Page::"QWESR WS Customer", 'OnGetExtraValues', '', false, false)]
local procedure OnCustomerGetExtraValues(Customer: Record Customer; var ExtraValue1: Text; var ExtraValue2: Text; var ExtraValue3: Text; var ExtraValue4: Text; var ExtraValue5: Text; var ExtraValue6: Text; var ExtraValue7: Text; var ExtraValue8: Text; var ExtraValue9: Text; var ExtraValue10: Text)
begin
ExtraValue1 := Customer.Bonus;
end;
[EventSubscriber(ObjectType::Page, Page::"QWESR WS Customer", 'OnModifyExtraValues', '', false, false)]
local procedure OnCustomerModifyExtraValues(var Customer: Record "Customer"; ExtraValue1: Text; ExtraValue2: Text; ExtraValue3: Text; ExtraValue4: Text; ExtraValue5: Text; ExtraValue6: Text; ExtraValue7: Text; ExtraValue8: Text; ExtraValue9: Text; ExtraValue10: Text)
begin
Customer.Bonus := ExtraValue1;
end;
Codeunit Web Services
The following events are published for Web Services of type Codeunit:
| Event | Description |
|---|---|
| OnBeforeInsert[Record] | This event is raised before the record is inserted. |
| OnAfterInsert[Record] | This event is raised after the record has been inserted |
| OnBeforeModify[Record] | This event is raised before the record is modified. |
How to Use Codeunit Web Services
You have added a field called Bonus on the Sales Header record. An external system wants to set this field when a new Sales Order is created. The external system will put this value in ExtraValue1. Then you can add this event subscriber to your PTE.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"QWESR WS Sales Document API", 'OnAfterInsertSalesHeader', '', false, false)]
local procedure OnAfterInsertSalesHeader(var SalesHeader: Record "Sales Header"; var WSSalesHeader: Record "QWESR tWSSalesHeader" temporary; var FieldsWithValue: List of [Integer]; var ExtraValue1: Text; var ExtraValue2: Text; var ExtraValue3: Text; var ExtraValue4: Text; var ExtraValue5: Text; var ExtraValue6: Text; var ExtraValue7: Text; var ExtraValue8: Text; var ExtraValue9: Text; var ExtraValue10: Text)
begin
if SalesHeader."Document Type" <> SalesHeader."Document Type"::Order then
exit;
SalesHeader.Bonus := ExtraValue1;
end;
Extra Value Field Mappings
ExtraValues can also be populated, and optionally written back, without writing any PTE code, using the Extra Value Field Mappings setup page. Map an extraValues slot directly to a field on the API page's source table.
Open the Spider - API Endpoints page, select an API page, and choose the Extra Value Field Mappings action to set up mappings for that page. For each mapping, select the Extra Value No. (1-10), the Source Table No., and the Source Field No.. Only one mapping is allowed per slot per API page.
The Read-only field is selected by default. Clear it to write the slot's value back to the source table field when the API consumer saves a record. Write-back is only available if both the API page and the selected source table support it. FlowFields are always read-only.
Tip
Avoid mapping a slot that a PTE OnGetExtraValues subscriber already
handles for the same API page. If both target the same slot, they run
independently and the last one to run wins, making the result unpredictable.
Note
Assigning the Configure API Extra Values (QWESR EXTVALMAP-ADM) permission set is required to insert, modify, or delete mappings.