Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OData v4 Syntax for Bound Actions? #191

Open
buzzwick opened this issue Apr 6, 2023 · 1 comment
Open

OData v4 Syntax for Bound Actions? #191

buzzwick opened this issue Apr 6, 2023 · 1 comment

Comments

@buzzwick
Copy link

buzzwick commented Apr 6, 2023

We are building out an OData v4 API in NAV version 14, using what documentation we can find--much of which relates only to AL. However, this is where our client is. Specifically, we need a couple of bound actions. One of these works as described in the documentation:
https://<server>/<service>/ODataV4/Company('<company>')/portalUser('520124')/NAV.SendPasswordReset
When we tried to create another bound action on another page, this one with a return value, we can see it in the $metadata but a Postman query returns
{ "error": { "code": "BadRequest_NotFound", "message": "The URI segment 'NAV.PrintDoc' is invalid after the segment 'purchHeader('PI10095')'." } }
Here is the query:
https://<server>/<service>/ODataV4/Company('<company>')/purchHeader('PI10095')/NAV.PrintDoc

We find that bound action procedures with return values cannot be accessed, whereas bound action procedures without return values work sometimes. We cannot seem to find what is the controlling factor. Nor can we find anything beyond the most basic documentation for this functionality, so we are flying blind.

Microsoft Support sent us to this forum, having been unable to find any resource that could explain this functionality in this version. In hopes that someone with experience with the OData v4 interface in version 14 NAV might turn up. Many thanks and apologies for having to post this on a BC repo.

@hellocontroltech
Copy link

hellocontroltech commented Jun 17, 2023

I'm relatively new to AL but I was trying to debug a similar issue myself, it turns out I needed to move ActionContext: WebServiceActionContext out of the procedure parameters. For example:

[ServiceEnabled]
[Scope('Cloud')]
procedure ShipOnly(ActionContext: WebServiceActionContext): Text
var
    SalesHeader: Record "Sales Header";
    SalesShipmentHeader: Record "Sales Shipment Header";
begin
    ...
    exit(SomeText);
end;

becomes

[ServiceEnabled]
[Scope('Cloud')]
procedure ShipOnly(): Text
var
    ActionContext: WebServiceActionContext;
    SalesHeader: Record "Sales Header";
    SalesShipmentHeader: Record "Sales Shipment Header";
begin
    ...
    exit(SomeText);
end;

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants