If Number of days passed allow field to become editable

DayzerDayzer Member Posts: 12
edited 2012-02-15 in Navision Attain
Guys,

I am looking for a bit of help here. I want to make a field become editable after one week, everyweek.

I am new to this, so please go easy :)

Cheers

Comments

  • SavatageSavatage Member Posts: 7,142
    What kind of field? Does this record have a start date or posting date that can be used to calculate it's age?
  • DayzerDayzer Member Posts: 12
    Savatage wrote:
    What kind of field? Does this record have a start date or posting date that can be used to calculate it's age?

    It is a password field - What I need is every week the user can change there password. Once a change has been made it will then become uneditable till the next week :)

    Thanks
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Is there any Date field existing on the table to calculate the week like "Last Modified Date".

    and in which table?
  • DayzerDayzer Member Posts: 12
    Is there any Date field existing on the table to calculate the week like "Last Modified Date".

    and in which table?

    Yes there is an existing field "Password Last Changed" which has the last time the password was changed.

    Its on a Staff table.

    Thanks :)
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Try this code in Form - OnAfterGetRecord() and Password Last Changed - OnAfterValidate() triggers..
    CurrForm.Pwd.EDITABLE := (CALCDATE('<-1W>',"Password Last Changed") > WORKDATE);
    
  • DayzerDayzer Member Posts: 12
    Try this code in Form - OnAfterGetRecord() and Password Last Changed - OnAfterValidate() triggers..
    CurrForm.Pwd.EDITABLE := (CALCDATE('<-1W>',"Password Last Changed") > WORKDATE);
    


    Mmmh Seems like Im missing something
  • SavatageSavatage Member Posts: 7,142
    edited 2012-02-15
    so "password last changed" is a datetime field?

    use this function
    Date := DT2DATE(Datetime)

    The datetime of which you want to return the date part.
    http://msdn.microsoft.com/en-us/library/dd301385.aspx
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I guess Password Last Changed is datetime field not date type...

    So try
    CurrForm.Pwd.EDITABLE := (CALCDATE('<-1W>',DT2DATE("Password Last Changed")) > WORKDATE);
    
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Guys, lets help Dayzer to do it properly.

    The correct way to do this is to add code to the onvalidate trigger of the field and give an error. Not making the field non editable in the form. [-X

    Can you imagine what you are teaching him? Instead of testing fields and checking as is standard in Navision, he is going to think its OK to write code that makes fields on forms editable to prevent users changing them.
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    DaysSinceLastChanged := TODAY-DT2DATE("Password Last Changed");
    if DaysSinceLastChanged < 8 then begin
    Error('Password Change Not Allowed');
    end else begin
    "Password Last Changed" := today;
    modify;
    end;

    but what's forcing them to make the change?
    What form/table is this "User Table"?, are you having it pop up each week by calcing the expiration date?
    are they changing it every week? why?
    If I had to change passwords every week I'd quickly forget which I have used last.
  • DayzerDayzer Member Posts: 12
    Savatage wrote:
    DaysSinceLastChanged := TODAY-DT2DATE("Password Last Changed");
    if DaysSinceLastChanged < 8 then begin
    Error('Password Change Not Allowed');
    end else begin
    "Password Last Changed" := today;
    modify;
    end;

    but what's forcing them to make the change?
    What form/table is this "User Table"?, are you having it pop up each week by calcing the expiration date?
    are they changing it every week? why?
    If I had to change passwords every week I'd quickly forget which I have used last.

    Well thanks everyone - Im going to do this right. So let me explain what I want to do :)

    I have a Password field that I need to change every Month for each ID.
    I need a msg to pop up every time it has to change.
    It needs to be forced every month.

    I am currently using a Staff table (This is not the main user table)

    Thanks everyone :P
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Dayzer wrote:
    I have a Password field that I need to change every Month for each ID.

    What do you mean by Password? If you mean the Navision log in password or something like that, then all this is managed in Active Directory and has no place what so ever in Navision.

    If this is some kind of secondary password management process, then maybe you are doing the whole thing wrong and need to explain what you are doing and why.
    David Singleton
Sign In or Register to comment.