NAV 2016 User permission for changing the WORKDATE

wittgensteinwittgenstein Member Posts: 17
Hi,

at first:
I'm new in the forum, so I apologize for eventually posting my topic in the wrong forum section. Also I apologize for any grammar mistakes as I am not a native speaker.

I'd like to only let permitted Users change the work date. I found several topics in the forum about this but unfortunately there was no solutionn for me.
According to my supervisor I must not use any timer-based solutions.

What are my options? There doesn't seem to be any specific trigger being executed after changing the work date...
I tried out several triggers in Codeunit 1 (OnDatabaseModify/OnDatabaseDelete/... , MakeDateText/MakeTimeText/...) but it didn't have any effect.

This is my code I want to run (it's in a separate Codeunit):
WorkDatePermissionCheck()
IF NOT UserHasPermission THEN BEGIN
  IF WORKDATE <> TODAY THEN BEGIN
    WORKDATE := TODAY;
    MESSAGE(Error001,USERID); // ERROR(Error001,USERID);
  END;
END;

UserHasPermission() : Boolean
IF NOT UserSetup.GET(USERID) THEN
  EXIT(FALSE);
EXIT(UserSetup."Allow Changing Workdate");

Thanks in advance
Wittgenstein

Best Answer

Answers

  • wittgensteinwittgenstein Member Posts: 17
    edited 2016-05-19
    Hey,

    thanks for your reply.
    Because you don't mention a reason why the WORKDATE may not be changed I assume it just is a 'security' measure requested by someone who doesn't understand NAV.
    Obviously. It's a customer request.

    a- This would probably take tons of changes in standard objects. I don't know if our customer would be happy with that. Nevertheless I will give it a try. OMA should help there.

    b- So you mean to modify the "Allow Posting From" and the "Allow Posting To" Fields in User Setup on startup? Hm. That wouldn't even require to touch standard objects in NAV 2016...
    Anyway. I have to clarify if our customer needs the work date user permission only for posting routines or also for other routines accessing the work date.

    Maybe I can convince our customer to just sensitize their Users to not touching the work date.

    However thanks for your answer. Let me know if you have more ideas. I'll let you know if I have found a solution for myself :smile:

    Edit
    My feedback:
    The only reliable option to suppress workdate change directly was a solution with a timer. It's not very elegant IMHO but it works.
    Anyways I decided to go with Peter+is1's suggestion 'b'. Thanks again for your help, Peter!

    As a side information: The workdate change is controlled in the executables of Dynamics NAV. So there is no way to manipulate and/or customioze this option directly.
  • wittgensteinwittgenstein Member Posts: 17
    Hey,

    I have another idea for a solution but I don't know if it would work.

    Can you somehow have access to the user32.dll or any other WinDlls (WinAPI)? Maybe with an Automation variable or a DotNet variable? Or do I have to write my own Dll in C# for accessing these functions?
    With FindWindow/FindWindowEx you can maybe get the window handle and manipulate it.

    As I said, I don't know if it works or if it is a silly idea but imo it's worth a try...
  • Peter+is1Peter+is1 Member Posts: 174
    I have some thoughts about that but those are way outside the scope of this forum... :)
    \\
    The truth exists in seven versions.
  • wittgensteinwittgenstein Member Posts: 17
    Do you mind sharing your thoughts with me :blush: ? I'm really interested. If you don't want to post it publically in this topic you can also send me a PM.
    I already managed to Hide and Disable the OK-Button in an external process. But I don't know how to use WinAPI functions out of NAV. Is this possible or do I have to create a "third-party" Dll?
Sign In or Register to comment.