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

Community site session details

Session Id :
Business Central forum
Under review by Community Managers

Under review

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

AL Extension to set manual tax amount on Purchase Invoice

Posted on by
Hi,
I'm importing, via web services, a bunch of historical PurchaseInvoice data into BC from another accounting system.  The data has, for whatever reason, many PurchaseInvoice lines where the tax amount is basically manually entered.  So that means the imported data can not be setup to use the built-in tax setups in BC.
There is a process in BC to manually override the tax in the user interface:
 
I'm looking to be able to do this using an AL extension and webservice.
 
The video shows that ultimately the user is modifying the PurchaseLine.Tax% field.  I have verified this by inspecting the page and viewing the PurchaseLine table and seeing the resulting value in the "Tax %" column.
 
The issue is that the "PurchaseLine.Tax %" field can not be added to the UI (it doesn't show up in the "Purchase Invoice > Lines > then "Help" > Inspect Page > Table Fields listing).
 
I also tried "Settings > Personalize > Lines > Add Field" but the "Tax%" field does not show up there either.
 
Similarly, in AL Extension code, creating a new extended card for PurchaseLine2 to show the field for "Tax%" results in a compile error:
 
 
Curious thing is that the webservices for PurchaseLines like:
https://api.businesscentral.dynamics.com/v2.0/xxxxxxxx/xxxxxxxxxx/ODataV4/Company('xxxxxxxxxxxx')/BLXPurchaseInvoiceLinesV2(xxxxxxxxxxx)
Shows the "taxPercent" field in the JSON results.
 
However if you try to post to that endpoint then you get an error:
"'POST' requests for 'BLXPurchaseInvoiceLinesV2' of EdmType 'Entity' are not allowed within Dynamics 365 Business Central OData web services."
 
So, I'm kinda stuck.  The field "Tax %" definitely exists on Purchase Line table.  But how can I access it and modify it? Ideally through an AL extension.
 
Thank you for your help with this.
Thanks!
Alex.
 
 
 

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans