Skip to main content

Notifications

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

FieldRef not changing at runtime

(0) ShareShare
ReportReport
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.

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans