Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

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

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
Categories:
  • gnlca Profile Picture
    gnlca 22 on at
    how to modify values in a custom field in Res. Ledger entry
    it worked!
    Thank you!
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 7,292 User Group Leader on at
    how to modify values in a custom field in Res. Ledger entry
    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
    gnlca 22 on at
    how to modify values in a custom field in Res. Ledger entry
    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,
     
  • Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 7,292 User Group Leader on at
    how to modify values in a custom field in Res. Ledger entry
    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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,986 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans