Custom API action to release Business Central blanket purchase orders using POST method with Microsoft.NAV.Release and JSON document number
|

Automate Blanket Purchase Order Releases in Business Central with Custom API Integration

If you’re working with blanket purchase orders (BPOs) in Business Central and want to automate or integrate their release process — especially from tools like Power Automate or external systems — you’re in the right place.

In this post, I’ll walk you through how to:

  • Create a custom API page for BPOs

  • Add a bound API action (Release)

  • Return structured JSON responses

  • Enable calling this action using the document number (e.g., PO-1234)

Step 1: Create the Custom API Page

This API exposes only blanket POs and uses the document number (No.) as the key:

				
					page 50100 "Blanket Purchase Order API"
{
    PageType = API;
    SourceTable = "Purchase Header";
    APIPublisher = 'powerlogichub';
    APIGroup = 'purchase';
    APIVersion = 'v1.0';
    EntityName = 'blanketPurchaseOrder';
    EntitySetName = 'blanketPurchaseOrders';
    ODataKeyFields = "No."; // Use document number as API key

    SourceTableView = WHERE("Document Type" = CONST("Blanket Order"));

    layout
    {
        area(content)
        {
            field("No."; "No.") { }
            field("Buy-from Vendor No."; "Buy-from Vendor No.") { }
            field("Status"; Status) { }
        }
    }

    [ServiceEnabled]
    procedure Release(): Text
    var
        ReleasePurchDoc: Codeunit "Release Purchase Document";
    begin
        if Rec."Document Type" <> Rec."Document Type"::"Blanket Order" then
            Error('Only Blanket Purchase Orders can be released using this action.');

        if Rec.Status = Rec.Status::Released then
            Error('The document is already released.');

        ReleasePurchDoc.Run(Rec);

        exit(Rec."No."); // Return the document number
    end;
}

				
			

Call the API from Postman / Power Automate

 

You can now release a blanket PO via HTTP:

				
					https://api.businesscentral.dynamics.com/v2.0/{Environment}/api/{PathToCustommAPI}/companies({CompanyGUID})/blanketPurchaseOrders('PO-1234')/Microsoft.NAV.Release
				
			

Remember to replace the {environment} {PathToCustomAPI} and {CompanyGUID} with your relevant details.  It would look something like:

 

				
					https://api.businesscentral.dynamics.com/v2.0/Sandbox/api/Mark/MarkGroup/v2.0/companies(3d2c5e71-b276-4f62-9a3d-e6db2e62bcb9)/blanketPurchaseOrders('PO-1234')/Microsoft.NAV.Release
				
			

If you are here reading this I will assume that you are aware of how to authenticate, if not I may cover that in a post at some point.  But remember to authenticate using OAuth 2.0

The output from this was that the blanket purchase order was release and we returned the PO number just because we want to return some data.

				
					{
  "documentNo": "PO-1234"
}

				
			

If the PO has already been released the result is an error explaining that the document was already released

				
					{
    "error": {
        "code": "Application_DialogException",
        "message": "The document is already released.  CorrelationId:  30245b64-1deb50bf8cd8."
    }
}
				
			

Conclusion

I wouldn’t say this is too advanced it’s a pretty simple API page but you could build it out to give you a better JSON response.  You could include the PO details includig header and line information in the JSON response, probably requiring a custom code unit to  create the output.  This is deffinitely moving into more advanced areas.  I suppose you could create functions to reopen the document if required, we could use this to integrate with document approvals.  I suppose you could use the same idea for releasing other documents such as sales orders or to post and ship orders. 

Let me know how you get on in the coments below.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *