web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

OnPostingLoad not working in API call x++

(0) ShareShare
ReportReport
Posted on by 209

Hi Community Experts,

I have one situation with the PurchaseOrderLinesV2 Data entity,

I have added some custom fields with "Is Computable Field" property set to "No.

And some methods in the entity through extension and I am calling those methods inside the "onPostingLoad" event handler of that data entity.

pastedimage1674453818786v1.png

This event handler is getting triggered fine and returning data in fields correctly when I am calling it through browser with this URL.

https://xxxxxxxxxxxxxxxxxxxxxxxxx.axcloud.dynamics.com/data/PurchaseOrderLinesV2

But when I call the same data entity from postman its not showing any data in the fields.

pastedimage1674454127251v2.png

"OnPostingLoad" is getting called when I am calling the entity from postman, but it is not returning data as it returns in browser.

Where should I put my code to get data in my custom fields?

Usual helpful responses are expected :)

Best Regards.

  • Martin Dráb Profile Picture
    241,432 Most Valuable Professional on at

    Your first test is using OData too, therefore if it works there, it proves that it does work. You're probably using different parameters from Postman. Please test the same thing - copy the request URL that Postman is using and open it in a browser.

    By the way, it seems that you've added an event handler to an extension class, which isn't the right approach and you should be getting a compuiler warning. The easist approach is using a CoC extension of postLoad().

    If you insist on an event handler, put it to a separate class.

  • alinawaz Profile Picture
    209 on at

    Hi Martin,

    Thanks for your suggestion about the extension class and event handler. I will do so.

    Upon further debugging I have found-out this buffer only has data when I call the entity from browser.

    pastedimage1674459012051v1.png

    When I call the same entity from Postman this buffer is empty.

    The request URL is same in postman and browser, the data I am passing in the method is same. This buffer is behaving differently in case of postman.

  • Martin Dráb Profile Picture
    241,432 Most Valuable Professional on at

    If you aren't aware of any difference in the data (using a different company or different trans ID), use the debugger to see the difference there.

    I suspect that VendRFQTrans isn't shared across companies (I can't check it at the moment) and therefore your code works correctly only if it's executed in the same company that you have in _dataAreaId.

  • Verified answer
    Martin Dráb Profile Picture
    241,432 Most Valuable Professional on at

    Yes, VendRFQTrans isn't shared across companies, therefore your query returns VendRFQTrans record from the current company (if such a record exists). Even if you call the code with identical parameters, you'll may different result if it's executed in different company context.

  • alinawaz Profile Picture
    209 on at

    Hi Martin,

    Thanks for pointing me to the correct direction.

    I just put the "Crosscompany" keyword in my select statement and its now working fine in postman as well.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 543 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 387 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 185

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans