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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to limit specific users in change WORKDATE

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Sometimes it might be requested that specific users should not be able to change their work date.

This could be achieved by a simple per tenant extension (PTE). Below the relevant code

The code below is related to version 14.x but it could be easily applied also to higher versions.

Create a table extension that extends User Setup table 

tableextension 50110 "UserSetupTableExt" extends "User Setup"
{
    fields
    {
        field(50110; "Change Workdate"; Boolean)
        {
            Caption = 'Change Workdate';
            DataClassification = ToBeClassified;
        }
    }
    
}
Create a page extension that extends User Setup list
pageextension 50110 "UserSetupListExt" extends "User Setup"
{
    layout
    {
        addlast(Control1)
        {
            field("Change Workdate";"Change Workdate")
            {
                ApplicationArea = All;
            }
        }
    }    
}
Create a simple codeunit that subscribe to OnBeforeWordDateChange in My Settings page
codeunit 50110 "Workdate Management"
{
    var
        UserSetup : Record "User Setup";

    [EventSubscriber(ObjectType::PagePage::"My Settings", 'OnBeforeWorkdateChange''', true, true)]
    local procedure OnBeforeWorDateChange(OldWorkdate: Date; NewWorkDate: Date)
    begin
        IF not UserSetup.Get(UserIdthen
          Error('You must enter a valid record for %1 in %2', USERID, UserSetup.TableCaption);
        if not UserSetup."Change Workdate" then
          Error('You are not allowed to change Wordate.');
    end;
}
That is all. 
How does it work.
After deploying the extension, search for (ALT+Q) User Setup table and check/uncheck the option "Change Workdate" for the user that may/may not be able to change the workdate
 
pastedimage1591712398165v1.png
For the users where this value is unchecked, every time they will try to change work date through my settings page, they will receive an error like 
pastedimage1591712481446v2.png
This post is provided as is. 
Happy coding.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans