web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

how to modify values in a custom field in Res. Ledger entry

(2) ShareShare
ReportReport
Posted on by 22
Hi everyone,
I created a new field called TestField in the table Res. Ledger entry.
Is there a way to modify the value in TestField via a procedure? For example I could create an action on the Resource Ledger Entries page which for each record in the table Res. Ledger entry copies the Entry No. to the TestField.
 
Thank you and best regards
I have the same question (0)
  • Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
    Hi @gnlca,
     
    Yes you can flow these steps :
    1 Table Extension (Res. Ledger Entry)
    tableextension 50109 "Res. Ledger Entry Ext" extends "Res. Ledger Entry"
    {
        fields
        {
            field(50100; TestField; Integer)
            {
                Caption = 'Test Field';
                DataClassification = ToBeClassified;
            }
        }
    }
    2 Page extension (Resource Ledger Entries)
    pageextension 50109 "Resource Ledger Entries Ext" extends "Resource Ledger Entries"
    {
        layout
        {
            addafter("Entry Type")
            {
                field(TestField; Rec.TestField)
                {
                    ApplicationArea = All;
                }
            }
        }
    
        actions
        {
            addbefore("&Navigate")
            {
                action(PopulateTestField)
                {
                    ApplicationArea = All;
    
                    trigger OnAction()
                    var
                        ResLedgerEntry: Record "Res. Ledger Entry";
                    begin
                        if (ResLedgerEntry.Get(Rec."Entry No.")) then begin
                            ResLedgerEntry.TestField := ResLedgerEntry."Entry No.";
                            ResLedgerEntry.Modify();
                        end;
                    end;
                }
            }
        }
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • gnlca Profile Picture
    22 on at
    Hi Mohamed,
    the code you proposed I already tried myself but it fails because the table Res. Ledger Entry is read only.
    The key is to make either the field TestField write enable and/or to catch the system method that is preventing my code to modify the value.
     
    Thank you and best regards,
     
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
    Hi @gnlca,
    You're right. 
    In that case I suggest you create a codeunit and add a permission set (Permissions = TableData "Res. Ledger Entry" = RMID) to it.
    pageextension 50109 "Resource Ledger Entries Ext" extends "Resource Ledger Entries"
    {
        layout
        {
            addafter("Entry Type")
            {
                field(TestField; Rec.TestField)
                {
                    ApplicationArea = All;
                }
            }
        }
    
        actions
        {
            addbefore("&Navigate")
            {
                action(PopulateTestField)
                {
                    ApplicationArea = All;
    
                    trigger OnAction()
                    var
                        test: Codeunit Test;
                    begin
                        test.UpdateTestField(Rec."Entry No.");
                    end;
                }
            }
        }
    }
    
    Codeunit
    codeunit 50105 Test
    {
        Permissions = TableData "Res. Ledger Entry" = RMID;
    
        procedure UpdateTestField(EntryNo: Integer)
        var
            ResLedgerEntry: Record "Res. Ledger Entry";
        begin
            if (ResLedgerEntry.Get(EntryNo)) then begin
                ResLedgerEntry.TestField := ResLedgerEntry."Entry No.";
                ResLedgerEntry.Modify();
            end;
        end;
    
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • gnlca Profile Picture
    22 on at
    it worked!
    Thank you!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans