Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Sales Shipment Line table - Added DateTime Column

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

So I added column 50000 "Shipment Date Time" as DateTime to the Sales Shipment Line table. I added this code to the table's OnInsert trigger:

OnInsert()

"Shipment Date Time" := CURRENTDATETIME;

The result is the George Washington date. I have tried various ways of doing this including On Validate of the Type and Item but to no avail. I even opened the table in sql and set the default date to GETDATE() on this column. Nothing!

I set the InitValue to 't' and it sets the date to today, but does nothing with the time.

The only thing that I have gotten to work is to add a Trigger to the Sql Table and it works up until somebody tries to do an 'undo' shipment and gets an error because of the trigger and cannot undo the shipment.

I don't understand why DateTime is such a difficult concept in NAV. Why doesn't my one line simple code "Shipment Date Time" := CURRENTDATETIME; work?

Thank you!

Kevin

*This post is locked for comments

  • Suggested answer
    Rabin Profile Picture
    Rabin 2,976 on at
    RE: Sales Shipment Line table - Added DateTime Column

    You can also create a function(or direct code) without parameter and call it before post function is being called in Post button onclick... :)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sales Shipment Line table - Added DateTime Column

    I only have application builder license. Codeunit 80 can only be modified with a developer license. This is the solution that will work but I was hoping to avoid  modifying a posting routine. Time to contact the consultant >_<

    Thanks for all the responses!

  • Suggested answer
    Rabin Profile Picture
    Rabin 2,976 on at
    RE: Sales Shipment Line table - Added DateTime Column

    Hi sayslah,
    I agree with Jonathan and Suresh...
    If you are familiar to how NAV works you can understand how the posting process works...

    In the systems there are four operations Create/Read/Update/Delete with their own triggers... In addition every field has its own Triggers, OnValidate/OnLookup. and there are further more details to take care if your field is related to posting process because it is then related to the Codeunit that handles the posting process[In your case it is Codeunit 80 : Sales-Post]...

    You can easily find the function inside the Sales-Post Codeunit that is used for posting. Just add your code there... So each time this function is called internally while posting the document your code will be automatically invoked...

    -------------- 

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 44,614 on at
    RE: Sales Shipment Line table - Added DateTime Column

    Kevin,

    The sales shipment line is created during posting of the shipment in the codeunit 80, during creation of shipment line it does not validate any fields nor it uses INSERT(TRUE) to execute Insert Trigger, the code uses TRANSFERFIELDS and assigns values directly so you need add a customization in the codeunit 80 to assign the Shipment Date Time value, search fro SalesShptLine.INSERT in the codeunit and before this statement add your above code and that should work.

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Sales Shipment Line table - Added DateTime Column

    when posting a sales order sales shipment header and sales shipment lines are created and filled.

    the insert trigger is called without parameter: SalesShptLine.INSERT;

    so the oninsert trigger is not called. means, it does not matter, how you set the value, with or without validate.

    so best chance is to follow the nav standard.

    edit cu 80 sales post and search for all positions, where SalesShptLine.INSERT is called. just before that call add your code, means SalesShptLine."Shipment DT" := CurrentDateTime;

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sales Shipment Line table - Added DateTime Column

    try VALIDATE("Shipment Date Time",(CURRENTDATETIME));

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans