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 :
Microsoft Dynamics NAV (Archived)

Automatically update document date when opening SO page

(0) ShareShare
ReportReport
Posted on by

Hi Dear,

Request : change the document date to workdate when the user enters the Sales Order Page

I know it's an old request (cf. 2005) ! How to manage this in RTC ?

and avoid "You cannot make any changes in the database until a transaction has been started. Sales order must close..."

TIA,

L

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Automatically update document date when opening SO page

    Under InitRecord()  in the Sales Header table this was set. It automatically take the work date as the Document Date as soon as the user start to enter the sale order.

    Error message you are getting is; you are trying to modify a sales header when there is no record.

    You can only able to change the date after you insert it to Sales header table.

    InitRecord() will only get executed only after Document Type,No. are entered to NAV by the user.

    Until those values are not completed NAV will not take this as record because Document Type,No. are defined as primary key of the table.

  • Suggested answer
    keoma Profile Picture
    32,729 on at
    RE: Automatically update document date when opening SO page

    hi,

    when opening a new sales order simple click into the "Sell-to Customer No." field (or every other field). then automatically the according new record with document type and no. is created. also the dates incl. the document date are set to the work date. and the error message is also not shown.

  • Community Member Profile Picture
    on at
    RE: Automatically update document date when opening SO page

    Hi

    My challenge is to change the Document date when the user come back to an existing SO.

    From the list of existing SO, you double click on one SO, the request of my customer is to change automatically the Document date when the Sales order appears in the page.

    Version is NAV2009R2 and the OnAfterGetCurrentRec doesn't exist...

    Regards,

    L

  • Community Member Profile Picture
    on at
    RE: Automatically update document date when opening SO page

    Hi,

    did you try putting the code on the OnAftergetRecord trigger on the page ?

    You might consider doing it conditionally (if WORKDATE <> "Document Date")

    kind regards,

    Francis

  • Community Member Profile Picture
    on at
    RE: Automatically update document date when opening SO page

    Tx Francis.

    This gives the message :

    "You cannot make any changes in the database until a transaction has been started. Sales order must close..."

    Best regards,

    L

  • Suggested answer
    Mohana Yadav Profile Picture
    60,967 Super User 2025 Season 2 on at
    RE: Automatically update document date when opening SO page

    It seems like you have written below code in OnAfterGetRecord trigger

    "Document Date" := WORKDATE;

    MODIFY;

    Please move MODIFY; to OnQueryClose trigger and try.

  • Community Member Profile Picture
    on at
    RE: Automatically update document date when opening SO page

    Tx Mohana

    Just > Currpage.update, which is necessary to show the new date

    Best regards,

    L

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Automatically update document date when opening SO page

    Agreed with Mohana,

    Write the below code in OnAfterGetRecord() trigger

    "Document Date" := WORKDATE;

    And then write the modify code in the OnQueryClosePage() trigger

    MODIFY;



  • Community Member Profile Picture
    on at
    RE: Automatically update document date when opening SO page

    Tx Tharanga.

    I agree with this, but it's far from a "clean" change of the date when entering the page, with the Document Date field validations.

    In final, I think that a trigger (OnAfterGetCurrentRec) is cruelly missing in NAV2009R2...

    Kind regards,

    L

  • Suggested answer
    4BzSoftware Profile Picture
    6,073 on at
    RE: Automatically update document date when opening SO page

    Hi Louis,

    Yes, there is no OnAfterGetCurrentRecord trigger for Page. But does it work for Form?

    For me, just input VALIDATE("Document Date", WORKDATE); in OnAfterGetRecord trigger of Page.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#2
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans