Hi,
What I am trying to achieve is quite simple. I would like to expose a page as a web service using odata. The web service is not supposed to do any insert to any table, I just want to do a simple calculation and return a value. I'll do some quick coding below to illustrate.
The only conditions that I have are:
* Not use new API.
* No insert to any table.
* Use ODATA
So, any recommendations on how to do it? I can easily achieve this using a codunit and soap, but it is not of interest in this case.
What I am trying to achieve is quite simple. I would like to expose a page as a web service using odata. The web service is not supposed to do any insert to any table, I just want to do a simple calculation and return a value. I'll do some quick coding below to illustrate.
The only conditions that I have are:
* Not use new API.
* No insert to any table.
* Use ODATA
page 50000 "Example Web Service"
{
PageType = Card;
SourceTable = "TempBlob";
SourceTableTemporary = true;
DelayedInsert = true;
layout
{
area(Content)
{
group(GroupName)
{
field(InputValueOne; InputValueOne) // User will provide this value in the request
{
}
field(InputValueTwo; InputValueTwo) // User will provide this value in the request
{
}
field(ReturnValue; ReturnValue) // I want to do some things in code and assign value to this variable and return it.
{
}
}
}
}
trigger OnInsertRecord(Belowxrec: Boolean): Boolean
var
begin
// Simplified code, but basically, I want to do stuff and assign a value to ReturnValue and return it in the odata response.
ReturnValue := 'Example Return Value';
end;
var // Global variables
InputValueOne: Text;
InputValueTwo: Text;
ReturnValue: Text; // Will contain a long Base64Encoded string.
}
// Below is not included in page, just sample json request body.
Example Request:
{
"InputValueOne": "Example",
"InputValueTwo": "Example Two"
}
Example Response:
{
"InputValueOne": "Example",
"InputValueTwo": "Example Two",
"ReturnValue": "" // This is always empty regardless of what I do to the variable in trigger OnInsertRecord.
}
So, any recommendations on how to do it? I can easily achieve this using a codunit and soap, but it is not of interest in this case.