Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic Date updating

Posted on 2009-05-20
10
Medium Priority
?
200 Views
Last Modified: 2013-12-18
Have a date field on a form which I need to dynamically update based on the changing of a status field. The status field will start with a Pending status. The date field would be blank to start. Anytime going forward if the status field is changed as it goes thru the process, the date field would be updated with that days date. Essentially this field would be the last date the status was changed.

Any help is appreciated.
0
Comment
Question by:jforget1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24431297
I normally handle this type of operation in LotusScript.

1) In the form's PostOpen event, save the initial value of your status field.  You can store the value in a global variable or in a computed for display field.  If this is a web app, then use a WebQueryOpen agent and store the value in a computed for display field.

2) In the form's QuerySave event, compare the current value of your status field with the initial value that you saved in the PostOpen event.  For a web app, do the same in a WebQuerySave agent.  In either case, simply set the date field to Today or Now if the status changed.
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 2000 total points
ID: 24431623
Yes, I use similar method, but it's usually better to compare values in QueryClose (from the point when user opens the doc, you usually don't want to register all saves, only the last one - so you wait for user to close the doc and register only values at that point).
On the other hand, you may want to know exact time the doc is last saved, it's up to your particular need.

Since you want to check the changes only if the doc was saved, create another global Boolean variable and set it to True in PostSave.
Globals - Declarations:
 Dim strOldStatus As String
 Dim flgDocSaved As Boolean
 
PostOpen:
 strOldStatus = source.document.strStatusFieldName(0)
 
PostSave:
 flgDocSaved = True
 
QueryClose:
 If flgDocSaved And strOldStatus <> source.document.strStatusFieldName(0) Then
     source.document.DateFieldName = Today
     Call source.document.Save( True, False, True )
 End if

Open in new window

0
 

Author Comment

by:jforget1
ID: 24434575
Just realized that I missed one element that might be an issue here. There are 10 different status fields for 10 different departments. Would the same code work?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24434593
Sure, you just need to have 10 global variables.
0
 

Author Comment

by:jforget1
ID: 24434605
OK working the code in now thanks.
0
 

Author Comment

by:jforget1
ID: 24434735
OK progress is happening, tried it first on just one record and it worked. I tired to code in a second status field, but that one did not update the date for the second group's date field. Below is the code I added into the Queryclose section. I am thinking I have the syntax wrong with the if...THen

	If flgDocSaved And exp_old_status <> doc.exp_status(0) Then
		doc.exp_date = Today
		If flgDocSaved And bd_old_status <> doc.bd_status(0) Then
			doc.bd_date = Today
			Call doc.Save(True,False)
		End If
	End If

Open in new window

0
 

Author Comment

by:jforget1
ID: 24434767
One other thing I noticed was that if I edited the doc and hit is esc,  it does not prompt me to save and the changes to the doc are not saving.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24434863
If you nest ifs like you did then bd_date wont change unless exp_date changed.

If I figured out right you mustn't nest ifs, like this:
Dim flgSomethingChanged As Boolean  'to avoid saving the doc multiple times
 
If flgDocSaved And exp_old_status <> doc.exp_status(0) Then
     doc.exp_date = Today
     flgSomethingChanged = True
End If
 
If flgDocSaved And bd_old_status <> doc.bd_status(0) Then
     doc.bd_date = Today
     flgSomethingChanged = True
End If
 
' ...  all other status/date fields
 
If flgSomethingChanged Then
     Call doc.Save(True,False)
End If

Open in new window

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24434895
Delete SaveOptions field from the doc.
It's obviously there with value 0 inside, which is used to exit without saving and prompting (when you want to force closing the doc from the code without asking user about it).

You can do it in PostOpen, like this:
Call source.document.RemoveItem( "SaveOptions" )

Open in new window

0
 

Author Closing Comment

by:jforget1
ID: 31583465
Excellent work here, this worked like a charm.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question