Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

In need of assistance with a coding issue in Business Central, with an EventSubscriber.

Posted on by 4
Hello everyone.
I'm a fairly new Developer, who has been given the chance to code in Business Central.


I’ve encountered a problem with my code, which I'm hoping someone can assistance me with.

Code currently:
[EventSubscriber(ObjectType::Page, Page::/item tracking Summary/, 'OnAfterGetRecordEvent', '', true, true)]

local procedure OnAfterGetrecordEvent(var Rec: record /Entry Summary/);

begin
if (Rec./Expiration Date/ > 0D) and (Rec./Selected Quantity/ > 0) then
message('Expiration Date is overdue!!! ' + format(Rec./Expiration Date/) + ' for item lot ' + Rec./Lot No./);
end;


Page/Table involved currently:
Page: 6500 & 6510
Table: 336 & 338

Purpose of code:
On page Item Tracking Lines (6510/336), once you click Proces, and Mark, the system automatically picks a Lot Number for my items (6500/338), I need my code to, at that point alert the user, if the Expiration Date is shorter than a custom Enum value set on customer card, rather than OD.



Issue I’ve encountered:
I cannot figure out how to connect my Event or Local Procedure to the Customer Card page, Record “Entry Summary” doesn’t have any info in it, which I can use to fetch data from Customer Card.

Once I get to page 6510 Item Tracking Lines, table 336 Tracking specification, the table is empty, until I click Process, Mark and then OK to finish adding the Lot Nr. (This is taking me to page 6500/table 338)
Now table 336 gets populated and has Order number etc.
(( Can I somehow fetch this data before the process is done? In order to look up for my Enum value?))


 
Categories:
  • Tech_BC_Gokul Profile Picture
    Tech_BC_Gokul 295 on at
    In need of assistance with a coding issue in Business Central, with an EventSubscriber.
    Hi 
     
    OnBeforeInitExpirationDate(Rec, xRec, IsHandled);
     
    Table 336 Tracking spefication 
     
    Try this method if that suites for your requirement 
     
    Thanks 
    Gokulnath 
  • KD-31050849-0 Profile Picture
    KD-31050849-0 4 on at
    In need of assistance with a coding issue in Business Central, with an EventSubscriber.
    Hello Tech_BC_Gokul,

    I tried looking into the Reservation Entry Table, I believe it's table 337
    But that table isnlt getting populated either before I press confirmoon table 338/ page 6500,
    So I'm in the same picky since I need some kind of data on table 338 / page 6500,

    Or am I mistaken, that the info is actually just not visible on 337 until I click 338, 
    But codingwise, it is actually there beforehand ?
  • Tech_BC_Gokul Profile Picture
    Tech_BC_Gokul 295 on at
    In need of assistance with a coding issue in Business Central, with an EventSubscriber.
    Hi, 

    Table 336 is a temparory table hence there won't be data stored in this record variable. 
    for all the item tracking entires you can get the relavent information from Reservation entries table. 
     
    Reservation entries will have the source document no & source document type. with that value you can setrange in Sales order to get the customer no. then filter the customer number in customer table you will get the value of the custom enum field. 
     
    With that scenario your questions can be anserwed

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans