Skip to main content

Notifications

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

Removing Posting Dates from User setup page

(0) ShareShare
ReportReport
Posted on by 105

Hello All,

Am creating a task scheduler that will run at midnight to remove all posting dates which was assigned to users, I know I have to create a code unit and later to create a job queue to perform a task, can you please help me on code unit part I have tried to do it but am facing some errors

local procedure UpdateUserSetup()
    var
        UseStp: Record "User Setup";
    begin
        UseStp.Reset;
        UseStp.SetRange("Allow FA Posting From", UseStp."Allow Posting From");
        if UseStp.FindSet(true, truethen
            repeat
                if UseStp."Allow Posting From" <> '' then begin
                    UseStp."Allow Posting From" := Format('');
                    UseStp.Modify()
                end;
            until (UseStp.Next() 0)

    end;
thank you for your assistance
  • Suggested answer
    Dallefeld Profile Picture
    Dallefeld 11,425 User Group Leader on at
    RE: Removing Posting Dates from User setup page

    Why are you removing this posting date control? This can be super helpful in controlling your accounting dates.

  • Maro9595 Profile Picture
    Maro9595 105 on at
    RE: Removing Posting Dates from User setup page

    Thank you, Vaishnav it works

  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,056 on at
    RE: Removing Posting Dates from User setup page

    Hi,

    you can write the codeunit logic like this 

    codeunit 50115 UpdatePostingdate
    {
        trigger OnRun()
        begin
            UpdateUserSetup();
        end;

        local procedure UpdateUserSetup()
        var
            UseStp: Record "User Setup";
        begin
            UseStp.Reset();
            UseStp.SetFilter("Allow Posting From", '<>%1', 0D);
            if UseStp.FindSet() then
                repeat
                    UseStp."Allow Posting From" := 0D;
                    UseStp."Allow Posting To" := 0D;
                    UseStp.Modify(true);
                until UseStp.Next() = 0;
        end;
    }
    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

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