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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

API with Custom Fields on OrderLine

(4) ShareShare
ReportReport
Posted on by 110

Hi, I have a problem, we talk about purchase orders.

1) I created custom fields on the Purchase Line table.
2) I cloned the header Standard API with APIGroup and APIPublisher.
3) I cloned the order lines Standard API, I added the custom fields with the trigger on the OnValidate and extended the source table (Purch. Inv. Line Aggregate).

The GET call on Postman works, I see the fields, but the custom fields are not valued.
Is there any code to add to make them pass from the Purch. Inv. Line to the Purch. Inv. Line Aggregate?

I’m not clear on this point.

Thanks!

I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,245 Super User 2025 Season 2 on at
    As long as you have the same field no. it should work but look at codeunit 5529, there are functions to transfer data.
  • Verified answer
    TGirli Profile Picture
    36 on at
    Since you've extended the Purch. Inv. Line Aggregate, the issue is likely that the data is not being transferred correctly from Purch. Inv. Line to Purch. Inv. Line Aggregate. Ensure the fields are mapped. You may need to explicitly map your custom fields in the API page extension. Try overriding the OnAfterGetRecord() trigger in your API page to manually pass values from Purch. Inv. Line to Purch. Inv. Line Aggregate.  
    Also make sure your API page extension actually includes the custom fields and that they are exposed with Field attributes.
       
    If you have triggers on OnValidate, ensure they are actually firing when the API fetches data. You might need an event subscriber to transfer the values before they are fetched by the API. If you’re still stuck, try debugging by inserting sample values directly into the Purch. Inv. Line Aggregate table and checking if they appear via Postman
     
     
  • Verified answer
    Ramesh Kumar Profile Picture
    7,529 Super User 2025 Season 2 on at
    Below things which I would check is below
     

    The custom fields on the Purchase Line are correctly written to the Purch. Inv. Line Aggregate (or any other related table).

    Use code to transfer values between these tables, either in the OnValidate trigger or via a custom procedure

    Ensure that field mapping is handled correctly during posting or invoicing

     

    Thanks, Ramesh

     

    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.

     

     


       
  • Verified answer
    GV-08111304-0 Profile Picture
    110 on at
    The mistake was very trivial and I thank you very much @Suresh Kulla for writing to check field no.

    The error was in having given a different Field No. for the custom field between Purch. Inv. Line and Purch Inv. Line. Aggregate.
    Now the values ​​of the custom fields with the trigger on OnValidate with RegisterFieldSet are correctly read by the Purch. Inv. Line. Aggregate.
     
    Thank you all!
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    Another option is to use WebService -> Odata directly, although the performance is not as good as APIs.
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,603 Super User 2025 Season 2 on at

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans