Call an OData Action from Power Apps Without Using Power Automate

Call an OData Action from Power Apps Without Using Power Automate

Call an OData Action from Power Apps Without Using Power Automate

Introduction

Most Dynamics 365 Finance & Operations (D365 F&O) implementations require business users to perform operational tasks quickly without jumping between multiple systems.

One common example is posting a Product Receipt against a Purchase Order (PO). Traditionally, if you want to post a product receipt from Power Apps, the common approach is to use Power Automate as a middle layer.

But here’s the good news:

You can directly call an OData Action from Power Apps and post a Product Receipt without Power Automate.

In this article, I’ll show you how.

What is a Product Receipt in Dynamics 365 Finance & Operations?

A Product Receipt is a document that confirms goods have been received from a vendor against a Purchase Order.

In D365 F&O, posting a product receipt is important because it:
• Updates inventory on-hand quantity
• Updates purchase order line status
• Creates inventory transactions
• Triggers downstream financial processes (depending on setup)

In real-life warehouse scenarios, users often need a faster mobile-friendly experience. This is where Power Apps becomes a perfect solution.

Why Avoid Power Automate for Posting Product Receipt?

Power Automate is great, but it introduces a few limitations:
• Additional licensing or flow run costs
• Latency (flow execution time)
• Debugging complexity
• Extra dependency layer

By calling OData actions directly from Power Apps, you get:
• Faster execution
• Cleaner architecture
• Better real-time user experience
• Fewer moving parts

Solution Overview

The solution is simple:
1. Create a custom OData Action in D365 F&O
2. Expose it through a Data Entity (or custom service endpoint)
3. Connect Power Apps to the D365 F&O environment
4. Call the action directly using the Power Apps connector

Step 1: Create a Custom OData Action in D365 F&O

To post a product receipt, you typically call the underlying posting logic available in the application layer (PurchFormLetter / ProductReceipt posting classes).

To expose this functionality externally, you create a custom OData action method on a Data Entity.

Example Scenario:
We create an OData Action called postProductReceipt.

This action will accept:
• Purchase Order ID
• Product Receipt Number
• InventTransId / Lot ID
• Quantity to receive

Step 2: Add the Action Method to a Data Entity

Create or extend a data entity such as PCH_PurchProductReceiptV1Entity and add an action method.

Sample X++ Code (OData Action Method):

[SysODataActionAttribute(“postProductReceipt”, true)]
public static void postProductReceipt(str _purchId, str _receiptNum, str _inventTransId, str _receivedNow, str _company)
{
 
        PurchTable        purchTable;
        PurchLine         purchLine;
        PurchFormLetter   purchFormLetter;
        List              purchLineList = new List(Types::Record);
        Qty               qtyNow = any2Real(_receivedNow);
 
        ttsBegin;
 
        changeCompany(_company)
        {
            purchTable = PurchTable::find(_purchId, true);
            if (!purchTable)
            {
                throw error(strFmt(“Purchase order % does not found”, _purchId));
            }
 
            purchLine = PurchLine::findInventTransId(_inventTransId,true);
 
            if (!purchLine)
            {
                throw error(strFmt(“Purchase order line % does not found”, _inventTransId));
            }
 
            purchLine.PurchReceivedNow = qtyNow;
            purchLine.modifiedField(fieldNum(PurchLine, PurchReceivedNow));
            purchLineList.addEnd(purchLine);
 
            if (!purchLineList.empty())
            {
                purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
                purchFormLetter.createFromLines(true);
                purchFormLetter.parmLineList(purchLineList.pack());
 
                // Post product receipt
                purchFormLetter.update(purchTable, _receiptNum, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), PurchUpdate::ReceiveNow);
            }
        }
 
        ttsCommit;
 
}

Step 3: Compile and Sync

Now, its time to compile the code, deploy to the connected environment and synchronize the database.

After deployment, your OData action becomes callable externally.

Go to Power Apps, select your environment and make this new entity available for Power Apps

Step 4: Connect Power Apps to D365 F&O

1. Go to Power Apps

2. Click on Data, + Add data and select your dataverse entity for Purchase orders(mserp) and Purchase order lines V2(mserp) to display all purchase orders with lines

3. Make Product receipt and Qty to deliver mandatory.

4. Once this field is filled in, you should enable OK button to Post Product receipt.

 

H2OGfkQRcvCLAAAAAElFTkSuQmCC

Step 5: Call the OData Action from Power Apps

In Power Apps:
1. Click on Data, + Add data and select your newly created Odata entity.
 (example: PCH Purch product receipt (mserp))

2. On OK button, write the below code to post product receipt.

IfError(
        ‘PCH Post product receipt (mserp)’.mserp_postproductreceipt(
            {
                _purchId:VarPO,
                _inventTransId:POLinesGallery.Selected.’Lot ID (mserp_inventtransid)’,
                _company:POLinesGallery.Selected.’Company Code’,
                _receiptNum:TextInputPR.Value,
                _receivedNow: QtyToDeliver.Value
            }
        ),
        Notify(FirstError.Message, NotificationType.Error, 3000),
        Notify(“Posting Product receipt successfully!”, NotificationType.Success, 3000)
    );

When a user clicks the Post Product Receipt button:

1. Power Apps calls the custom OData action:

‘PCH Post product receipt (mserp)’.mserp_postproductreceipt()

2. It sends required purchase order and receipt details to Dynamics 365.

3. If the operation fails → an error message is shown.

4. If the operation succeeds → a success message is shown.

The function sends the following values to Dynamics 365:

P8PNJ+UlhaMMwAAAABJRU5ErkJggg==

Conclusion

Power Apps is not just for viewing data. it can also trigger real transactions inside Dynamics 365 Finance & Operations.

By exposing an OData action and calling it directly, you can build lightweight apps for:
• Product receipt posting
• PO confirmation
• Vendor invoice posting
• Inventory movements
• Transfer order receipt/shipment

This approach is fast, clean, and avoids the need for Power Automate.

Parag Chapre

Parag Chapre is a Microsoft MVP in the fields of Dynamics 365 Finance & Operations, Human Resources, and Power Platform, recognized for his outstanding contributions to the Microsoft Dynamics community.

With over 15 years of hands-on expertise in various Microsoft Dynamics 365 areas, Parag has designed and delivered complex, innovative solutions for customers across industries and geographies. He has also provided leadership and technical guidance to project teams, managed offshore and onshore resources, and worked closely with Microsoft Product teams. Parag is passionate about sharing his knowledge and insights through his personal website, blog posts, articles, and community events. He is a member of the Microsoft Biz Apps Community Advisory Board, a Dynamics 365 Human Resource Community star, a Dynamics 365 Community contributor, and a Dynamics 365 Community Spotlight honoree.

Leave a Reply

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