Extra Values
ExtraValues is a concept in Spider that makes it possible for a PTE developer to extend the Web Services, 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.
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;