How to make sure a user cannot EDIT a date field once it's created

Hi,

I have a date field, I want a user to be able to create a date, but not have this user able to edit the data after that. I want to use MGR role to allow MGR to edit this date.

I am able to do this for the WHOLE form, however I am NOT able to do this JUST for ONE field / date field...

Here's my code I use on Querymodechange

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
      Dim curdoc As notesdocument
      
      Set curdoc=Source.document
      
      If Not ( source.EditMode ) Then
  'user_roles = Evaluate( "@UserRoles" )
            user_roles =Evaluate("@UserNamesList")
            Forall role In user_roles
                  
                  If ( role = "[MGR]")   Then
                        
                        continue=True
                        Exit Sub
                  End If
                  
            End Forall
      End If
      If curdoc.STATUS(0)="Open" Or curdoc.STATUS(0)="On Hold" Then
            continue=False
            Source.Close
       'Exit Sub
      End If
      
End Sub

and under Postmodechange

Sub Postmodechange(Source As Notesuidocument)
      
      Dim status As String
      status = Source.FieldGetText("Status")
      
      Call Source.FieldSetText("StatCheck" , Status)
      
End Sub
car701015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbonaciCommented:
Create Computed text bellow field and then use hide-when formulas to control to whom you'll show each of them.
0
mbonaciCommented:
One suggestion, looking at your PostModeChange event code, you should use

    if source.EditMode Then
    ...

to check whether user changed doc to edit mode or read mode (click on <ctrl + e> while in edit mode will cause error in your current code).

One more thing, computed text should have this as its formula:

    @Text( name_of_your_field_without_quotes; "D0" )

if you want to show only date component of date/time field.
0
car701015Author Commented:
Thanks mbonaci, one problem though, if I make a computed field, the original field has an advance date, meaning that it will permanently hide, when a user creates a new record, I want them to decide to either use existing advanced date or they set a new date.

tks for the other mention...
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

mbonaciCommented:
Not computed field, Computed text.
You don't change anything on your existing date field (except hide formula), simply position the cursor right of it and click enter.

Then choose

    Create > Computed text

and write the formula I mentioned in the lower right frame.
0
mbonaciCommented:
Just a simple demonstration:

In your current date field's hide-when properties enter this formula:

    !@IsNewDoc

and in <Computed text> properties this one:

    @IsNewDoc

This way the two paragraphs are mutually exclusive, the date field will show before, and the <computed text> after the doc is saved.
0
mbonaciCommented:
You can base the hide-when formulas on a "flag field" (non-existent on the form, written in run-time only to a document).
That way you can manipulate hide-when formulas so you can customize the form behavior as it suits you best.
0
car701015Author Commented:
Ah, ok, I got this

field hide formula...

@IsMember("[MGR]";@UserRoles) = 0 | !@IsNewDoc

computed text

@Text(@Date(date_target); "D0" )

hide formula
@IsNewDoc

but I am the MGR, if I want to change the date, it doesnt allow me to...
0
car701015Author Commented:
oh... and since the computed text... I am now getting

"You must be in Edit Mode to Change the value of a field"
0
mbonaciCommented:
Two things, first you don't need "=0" in:
@IsMember("[MGR]";@UserRoles) = 0

Use
    @IsNotMember("[MGR]";@UserRoles)
or
    !@IsMember("[MGR]";@UserRoles)


Second, you can use @IsDocBeingEdited inside hide-when formula, instead of "You must be in Edit Mode to Change the value of a field".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
car701015Author Commented:
!@IsDocBeingEdited | @IsNotMember("[MGR]";@UserRoles) was used - Thank you very much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.