Skip to main content

Notifications

Microsoft Dynamics NAV forum
Answered

FieldRef not changing at runtime

Posted on by Microsoft Employee

In Navision 2018 CU2, we have codeunit that makes sales/purchase invoices/credit memos from custom tables that contain records with the data for the header and the lines for these documents.
(These custom records are published via API pages so an external accounting software can send their data to these records; this is an integration of an external accounting software with NAV).

The Due Date can differ from the Due Date calculated using the Payment Terms in Navision.

First, we validate the payment terms code in Navision.
After that, we validate the Due Date from that custom table.

This has been tested and this has worked before:
The correct Due Date (from our custom page) was on the sales/purchase document (not the Due Date calculated by the Payment Terms in Navision).


The code is as follows

lFieldRef := lRecRef.FIELD(23); //Payment Terms Code
lFieldRef.VALIDATE;

lFieldRef := lRecRef.FIELD(24); //Due Date
lFieldRef.VALIDATE(lRecCustomHeaderTable."Due Date");

Recently however, this stopped working correctly.
Nothing in the code has changed.
The entire Navision server has been rebooted but the problem remains.

Debugging shows that lFieldRef keeps pointing to field(23) even when the debugger reaches the line below:
lFieldRef.VALIDATE(lRecCustomHeaderTable."Due Date");

For some reason, "lFieldRef := lRecRef.FIELD(24);" does not trigger pointing to field 24 but keeps pointing to field 23.

(lRecRef is either 36 (Sales Header) or 38 (Purchase Header), depending on the incoming document being a sales or purchase invoice/credit memo.)

This seems strange behaviour.
Does anyone have any experience with a similar problem or perhaps even be aware of a fix?

Many thanks.

Categories:
  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,640 on at
    RE: FieldRef not changing at runtime

    Try using CLEAR(lFieldRef) that way it clears and will reset.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans