Prevent Work Date change

fmhiguefmhigue Member Posts: 290
Hi everybody:
I made some changes to Codeunit 1 - ApplicationManagement on MakeDateText. I added the following code:

MemberOf.SETCURRENTKEY("User ID","Role ID",Company);
MemberOf.SETFILTER("User ID",USERID);
IF MemberOf.FIND('-') THEN
REPEAT
IF MemberOf."Role ID" <> 'SUPER' THEN
SuperUser:= FALSE
ELSE
SuperUser:= TRUE
UNTIL (SuperUser = TRUE) OR (MemberOf.NEXT=0);

IF UserSetup.GET(USERID) THEN
IF UserSetup."Allow Change Work Date" = TRUE THEN
WorkDateModifyUser := TRUE
ELSE
WorkDateModifyUser := FALSE;

IF (SuperUser = FALSE) AND (WorkDateModifyUser = FALSE) THEN
BEGIN
PreWorkDate := WORKDATE;
MESSAGE('You are not authorized to change Work Date. Please contact your manager.\'
+ '\Usted no esta autorizado para cambiar el Work Date. Por favor contacte a su gerente.');
DateText := FORMAT(PreWorkDate);
WORKDATE := PreWorkDate;
EXIT(1);
END

It works fine preventing not allowed users to change the Work Date. But now I got a problem with users that run Aged Accounts Receivables Reports, Aged Vendor Report, etc. They are getting the same error message. Like it they were trying to change the workdate. Any ideas?

Thank you in advance

Comments

  • BeliasBelias Member Posts: 2,998
    They are getting the same error message.
    When?when they're trying to insert a date?
    because AFAIK, makedatetext is called everytime you write in a date field/variable...(anyway, i've never modified it)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • fmhiguefmhigue Member Posts: 290
    Any ideas thow to get around of my problem?

    Thank you
  • matttraxmatttrax Member Posts: 2,309
    Why do you need to prevent them from doing this? And why would they?

    It shouldn't be because of posting, you can just change the allowed posting dates for the users.

    I think you should just train the users not to change it. If they can't follow directions then you have a problem with the employee. Most users don't even know what a workdate is from what I've seen, much less how to change it.
  • garakgarak Member Posts: 3,263
    Please sai, why do you want to prevent them?
    Only, like matttrax said, for posting?
    Do you make it right, it works too!
  • kapil4dynamicskapil4dynamics Member Posts: 591
    matttrax wrote:
    I think you should just train the users not to change it. If they can't follow directions then you have a problem with the employee.

    This seems more feasible solution than using hammer on system.
    Kapil Khanna
  • fmhiguefmhigue Member Posts: 290
    Mattrax it is just what you said we have the bad habit of being changing workdate. It is a company problem to be honest but some managers are the ones making those mistakes so it does not apply the same for them.

    matttrax
  • hawkeyehawkeye Member Posts: 51
    I have a customer with A LOT of scedulers. They changed their Workdate by mistake to 1 year ahead and all the sceduled tasks where triggered.

    We cannot use TODAY instead of WORKDATE because of supprt issues.

    I´m considering a code in CU 1
  • matttraxmatttrax Member Posts: 2,309
    I'm all for "error-proofing" the system at time, but I don't think this is one of them.

    Try putting a warning message in, if the workdate is more than a certain amount past the schedule date it will say "Are you sure you didn't make a mistake?"

    Users will make mistakes, even with training, but the best you can do is tell them to pay attention to what they are doing.
Sign In or Register to comment.