Field locked for editing

isabtogumonisabtogumon Member Posts: 30
Hi,

I want to edit the last modification date in the Item Card after adding or modifying the Unit of Measure records but I have not succeeded and I suppose it is because the field is blocked

I have tried it this way:
    [EventSubscriber(ObjectType::Page, Page::"Item Units of Measure", 'OnInsertRecordEvent', '', true, true)]
    local procedure OnNewItem(var Rec: Record "Item Unit of Measure")
    var
        Item: Record Item;
        ItemCard: Page "Item Card";
    begin
        Item.SetCurrentKey("No.");
        Item.SetRange("No.", Rec."Item No.");
        if Item.FindSet() then begin
            Message('Successful in Item No.: %1', Item."No.");
            ItemCard.Editable := true;
            Item."Last Date Modified" := Today;
            Item."Last DateTime Modified" := CurrentDateTime;
            Item."Last Time Modified" := DT2time(CurrentDateTime);
            ItemCard.Update();
            ItemCard.Editable := false;
        end;
    end;

How can I unlock a field for editing after inserting or modifying records?

Answers

  • KishormKishorm UKMember Posts: 921
    [EventSubscriber(ObjectType::Page, Page::"Item Units of Measure", 'OnInsertRecordEvent', '', true, true)]
        local procedure OnNewItem(var Rec: Record "Item Unit of Measure")
        var
            Item: Record Item;
        begin
            if Item.Get(Rec."Item No.") then begin
                Item."Last Date Modified" := Today;
                Item."Last DateTime Modified" := CurrentDateTime;
                Item."Last Time Modified" := DT2time(CurrentDateTime);
                Item.Modify();
            end;
        end;
    
Sign In or Register to comment.