Who is this guy?

PlanetLotus.org

Idea Jam

Flickr Photos

www.flickr.com
This is a Flickr badge showing photos in a set called BlogPics. Make your own badge here.

Blogroll

The Badges

July 16th, 2009

S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent

This may be old hat to some of you, but it was new to me, so I'm posting it even if it's only for my benefit in some future coding endeavor.

I have some documents in a view which have a computed "days past due" field which calculates based off another computed/looked-up field and the current day's date. 

Nothing else on the document is computed or in any way complicated, so I thought I'd just see if I could find a way to re-compute the documents each day.  While doing some searching in the 6 and 7 forum, I came across this gem.

Instead of a running on a collection, I just have it run through my view and it does the job neat and tidy, and I have it scheduled just after midnight so all is good for the day when the users look at the view.

Set doc=mr_view.getFirstDocument
 
Do While Not doc Is Nothing
  Call doc.ComputeWithForm(True,False)
  Call doc.save(True,False)
  Set doc=mr_view.getNextDocument(doc)
Loop

I hadn't known you could use computewithform in this way, but it appears you can...

Gotta love 6 1/2 year old forum posts!

[1] S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent
Created 7/16/2009 8:39:27 AM by Chris Toohey
(Chris Toohey http://www.dominoguru.com)

Hey Phil!

This works great with "old"-architectures, where the developer didn't properly separate UI from the NotesDocument, but I would warn against this approach as a "method to update NotesDocuments" for today and tomorrow's applications.

I'm more than likely preaching to the choir here, but once you separate UI from the back-end data store (in this case, a NotesDocument), you have literally limitless capabilities with managing and maintaining your content.


[2] S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent
Created 7/16/2009 9:54:01 AM by Phil Randolph
(Phil Randolph http://philrandolph.com)

Thanks for commenting Chris.

I definitely wouldn't be doing this as an "all the time" thing. I don't have a bunch of "new-fangled" applications with the UI and back-end extremely separated and in this instance it did what I wanted to do on a very simple document.

Just wanted to make people aware of the ability to do it, but definitely not touting it necessarily as a "best practice".


[3] S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent
Created 7/16/2009 9:58:02 AM by Kevin Pettitt
(Kevin Pettitt http://www.lotusguru.com)

One gotcha is when some of those computations are dependent on values in computed for display fields, in which case they don't work, as discussed in this thread for example: { Link }

Oddly though, @Command([ToolsRefreshSelectedDocs]) DOES work properly even with CFD fields, though you have to run it manually.


[4] S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent
Created 7/16/2009 12:43:08 PM by Phil Randolph
(Phil Randolph http://philrandolph.com)

Good catch Kevin.

Fortunately I don't have any CFD fields in this instance, certainly none that are of any consequence to computations.


[5] S&TT - Using ComputeWithForm to Refresh documents via a Scheduled Agent
Created 7/16/2009 12:55:51 PM by Kevin Pettitt
(Kevin Pettitt http://www.lotusguru.com)

Oh, and I should have mentioned this earlier but there is a no-touch approach to achieving essentially the same goal of recalculating a date-based view. I blogged it here (via Sean Burgess) { Link }


[6] 14th Anniversary
Created 4/17/2012 8:30:52 PM by Coach Outlet Online
( http://www.getcoachoutletsonline.com/)

nice post !!


Add Comment
 
Subject:
   
Name:
E-mail:
Web Site:
 
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     
December 2013
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

OpenNTF.org

Latest Googles

Latest Referrers

Credit where it's due

Special thanks to Chris Miller at Connectria for providing hosting services for this site.

How many did you say?

brave souls have visited this strange place

Super Secret Web Admin Thingie ;-)