Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Removing Posting Dates from User setup page

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
Categories:
  • Suggested answer
    Dallefeld Profile Picture
    Dallefeld 11,423 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans