Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : lj597+05LvlEvoDtUO+J0l
Small and medium business | Business Central, N...
Answered

API with Custom Fields on OrderLine

Like (3) ShareShare
ReportReport
Posted on 14 Mar 2025 11:58:17 by 68

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!

  • Suggested answer
    YUN ZHU Profile Picture
    78,830 Super User 2025 Season 1 on 16 Mar 2025 at 23:39:49
    API with Custom Fields on OrderLine
    Another option is to use WebService -> Odata directly, although the performance is not as good as APIs.
     
    Hope this helps.
    Thanks.
    ZHU
  • Verified answer
    GV-08111304-0 Profile Picture
    68 on 14 Mar 2025 at 16:27:26
    API with Custom Fields on OrderLine
    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!
  • Verified answer
    Ramesh Kumar Profile Picture
    979 on 14 Mar 2025 at 15:52:05
    API with Custom Fields on OrderLine
    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
    TGirli Profile Picture
    21 on 14 Mar 2025 at 12:35:35
    API with Custom Fields on OrderLine
    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
    Suresh Kulla Profile Picture
    45,273 on 14 Mar 2025 at 12:34:28
    API with Custom Fields on OrderLine
    As long as you have the same field no. it should work but look at codeunit 5529, there are functions to transfer data.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,927 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,793 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete