Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

I want to get the new value of field using its no

Posted on by 47

I want to get the field`s Value using its No I tried using Recref and FieldRef but it keeps giving the old value not the modified one 
this is the code: 

tableextension 50006 "XEE Customer" extends Customer
{



    fields
    {
        modify(Name)
        {
            trigger OnAfterValidate()
            var
                myInt: Integer;
            begin
                WhenFieldIsModifies(Rec.FieldNo(Name), rec."No.");
            end;
        }
    }
   



    procedure WhenFieldIsModifies(FieldNo: Integer; RecNo: Code[20])
    var
        MasterCust: Record "XEE Master Customer";
        recRF: RecordRef;
        fldRef: FieldRef;
        Cust: Record customer;
    begin
        Cust.SetRange("No.", "No.");
        if Cust.FindFirst() then begin

            // if MasterCust.get(rec."No.") then begin
            recRF.OPEN(Cust.RecordId.TableNo, FALSE);
            recRF.Get(Cust.RecordId);
            recRF.GetTable(Cust);
            // recRF.SETTABLE(Cust);
            recRF.FINDFIRST;

            fldRef := recRF.FIELD(FieldNo);
            Message(Format(fldRef));
        end;
        // end;
    end;
}
Can I get the  new value onValidate using Recref and FieldRef?
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,472 Super User 2024 Season 2 on at
    RE: I want to get the new value of field using its no

    Hi, try using trigger OnAfterModify(), I tested it and there is no problem.

    pastedimage1686876468731v3.png

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: I want to get the new value of field using its no

    If you want to retrieve the current modified name, you can use Rec.Name in your trigger. If you want to get the current record using the field ID, you can refer to the following link for more information, learn.microsoft.com/.../fieldref-value-method

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans