Options

How to deny Work Date change?

goagoa Member Posts: 10
Hi.

Security question.

We need to block attempts of changing working date for some users.
Is it possible to allow/deny changing Work Date (Tools | Work Date) via standard permissions functionality?

Any suggestions?

Comments

  • Options
    tinoruijstinoruijs Member Posts: 1,226
    No. That's not possible.
    You could use the fields "Allow Posting From" and "Allow Posting To" in the User Setup table to control the dates users can use.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • Options
    goagoa Member Posts: 10
    tinoruijs wrote:
    No. That's not possible.
    You could use the fields "Allow Posting From" and "Allow Posting To"

    That's not useful for purposes we'd like to limit date change.

    D-oh! Coding, coding, coding...
  • Options
    garakgarak Member Posts: 3,263
    its not possible with permissions. But when changing the workdate, the CU1, i belive Function MakeDate (or so), will called. So here you can store your code.
    Do you make it right, it works too!
  • Options
    goagoa Member Posts: 10
    garak wrote:
    ...when changing the workdate, the CU1, i belive Function MakeDate (or so), will called...

    And it's also called from everywhere from the date fields, when you chane date, for example...

    Also, I'm trying to keep CU1 unchanged.

    So, I should make mods in a range of interesed objects...

    thanks all!
  • Options
    SavatageSavatage Member Posts: 7,142
    How do you mean Limit?

    Posting date = work date?
    posting date = today?

    or a range of a day either way or a range for a month?
  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    I didn't try that but you could create a single instance codeunit which is called from CU1 and do every 10 Seconds
    IF WORKDATE <> TODAY THEN
      WORKDATE := TODAY;
    
    You could make it more comfortable and check if the user is allowed to change the workdate.
    Therefore add a field to table User Setup (e. g. "Allow change Workdate")
    Then the code in your single instance codeunit looks like this:
    IF UserSetup.Code <> USERID THEN  // This line is for performance
      IF NOT UserSetup.GET(USERID) THEN
        UserSetup.INIT;
    IF (NOT UserSetup."Allow change Workdate") AND
       (WORKDATE <> TODAY)
    THEN
      WORKDATE := TODAY;
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    goagoa Member Posts: 10
    Savatage wrote:
    Posting date = work date?
    posting date = today?

    Actually, posting date <> workdate...
    I didn't try that but you could create a single instance codeunit which is called from CU1 and do every 10 Seconds

    Hm... Looks useful.

    Will also try to allow every System except 0 in Permissions.
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    goa wrote:
    garak wrote:
    ...when changing the workdate, the CU1, i belive Function MakeDate (or so), will called...

    And it's also called from everywhere from the date fields, when you chane date, for example...

    Also, I'm trying to keep CU1 unchanged.

    So, I should make mods in a range of interesed objects...

    thanks all!

    Just modify CU1, that is the best way.
    David Singleton
  • Options
    garakgarak Member Posts: 3,263
    when you not will touch the CU 1, you must create your own CU. But to work with this CU, it must called from CU1.

    Or, your Codeunit is Singlieinstance and loaded in Function LoginStart and with Timer it go throw every x seconds. but this way #-o

    So easiest and best way: modify cu1. You can make here your own function which is called from the function i sayed. In your function you handle the user permissions.
    Do you make it right, it works too!
Sign In or Register to comment.