Fill a record from response JSON data based on response body settings. The record can then be used for further processing with code.
Text
- Specifies the path to the JSON node with data of the record in JPath notation. The response body node must have Type
Table.Variant
- Specifies the record variable that should be filled from JSON data.Boolean
True if the JSON node was found and processed, false otherwise.
var
SalesHeader: Record "Sales Header";
SalesLine: Record "Sales Line";
RecVariant: Variant;
RecordFound: Boolean;
//Call the operation to get data
APIScriptRWU.INIT("Operation ID RWU"::RWUTest_GetOrders);
APIScriptRWU.ENDPOINT("Provider ID RWU"::RWUTest, "Operation ID RWU"::RWUTest_GetOrders);
APIScriptRWU.EXECUTE();
//Fill the Sales Header record with data of the first order in JSON
RecVariant := SalesHeader;
RecordFound := APIScriptRWU.FILL_RECORD_FROM_RESPONSE('$.orders[0]', RecVariant);
SalesHeader := RecVariant;
//Use and process the record
if RecordFound then begin
SalesHeader."Document Date" := Today();
SalesHeader.Insert();
end;
//Fill the Sales Line record with data of the second line from the first order
RecVariant := SalesLine;
RecordFound := APIScriptRWU.FILL_RECORD_FROM_RESPONSE('$.orders[0].lines[1]', RecVariant);
SalesLine := RecVariant;
If the Table View is defined in the table node details, the function will first try to fill the key fields. These fields are always validated. (Note, that the Table Operation field is not necessary and should be blank in most cases – this is used for data update by RapidStart package.)
Then it goes through child nodes with Type Field
and fills the data into the selected fields.
These fields are validated by default, but the validation can be switched off in node details.