PermaLinkBigBill's Big 7, number 608:41:23 AM
Written By : Scott Good

Allowing simultaneous document updates without replication conflicts

This was one of the last just-plain-cool ideas Bill cooked up for us. Here's the situation: You have a form which lists out responsibilities for any number of different people. A Training Plan, for instance, where you have the names of all the people who need to be trained and, along with them, the names of the individuals assigned to train each one:

EmployeeTrainer
Sam JohnsonNita Smeans
Alice WanGeorge Wilson
Dave SmithDoug Adams
Jack JacobsonNita Smeans
Wally WilsonRoger Winters

Something like that. As each person's training is completed, the trainer should be able to open this document and indicate completion. As a part of that, the form should be updated with the current date and time so everyone can know exactly who was trained and when.

The problem is you have many different trainers who may be trying to update the Training Plan at the same time. If you open it and I open it and we both make changes and save the document, guess what? We'll get replication conflicts.

Now, if we're both working from the Notes client, there are ways to guard against this. Given the same server, it will at least warn you if you try to save your document after I've saved mine. Also, it's pretty straightforward to build a means of preventing two people from editing the same document at the same time if you're using the client.

But what about from the web? In a stateless environment like the web, where the server really has no idea whether you're still looking at that page it sent you a while ago, how can you keep replication conflicts from happening and yet retain the user experience.

This was the challenge we faced.

Like so many things in life, the solution was simple once we finally hit on it. Here's what we did:

At first we thought we had to find a way to know when one person was editing a document so we could prevent others from editing it at the same time. I'll spare you the details but the short version of the story is: Don't waste your time. You can't tell.

Then we came at it from the other way: How can we let lots of different people make editing changes to the same document, at the same time, from the web, without creating replication conflicts? You can chew on it for a while but the only answer (that we could come up with, anyway) was to not allow any editing of the document directly but, instead, to do all the updates with a WebQuerySave agent.

WebQuerySave agents are single-threaded. That means only one runs at a time. So, if you and I and three other people all call the same WebQuerySave agent to run on the same document at the same time, well, it's going to do them sequentially. It will do one, then the next, then the next, and so on, until it finishes, but each will run separately.

So what we needed to do was get the WebQuerySave agent to run for us on the right bits of data. But WebQuerySave agents only run when you're saving a document and we specifically don't want to save the document (and risk creating replication conflicts). So, how to trigger it?

One way would just be to call an agent via a URL, but we decided to make a separate form which acted as a dialog box to verify your intent to continue. Pressing the OK button actually submitted that form, to which we had passed enough parameters to be able to know exactly which entry needed updating. At the end of the WebQuerySave agent it either deleted the dialog form (if the update was successful) or saved it in the database for later processing (if it failed for some reason).

Making the user experience less unsatisfying

The problem with this approach is everything was being done in the background. You'd press a button, verify your intent to continue and the WebQuerySave agent would go do the update to the underlying document...but you couldn't see the change in the browser without refreshing it.

As user feedback goes, that's pretty bad. When I've pushed the button to do the update, I want to be able to see it on the screen to know things worked properly. But, if the change is actually made on the screen, doesn't that mean I'm changing the document (and, thus, risking replication conflicts)?

Not necessarily.

On the form, each of the Trained-On dates was contained in a span, something like this:

<span id="trainDate01"></span>

On a line where training had been completed, of course, the value would show up inside the span. That's easy enough to do: put a field or some computed text in there and it will compute when the document is loaded to the browser. But what about the new ones, the lines where I've just pushed the "Training completed" button and expect to see something?

It turns out, that's simple, too. From the dialog form, when you press "OK," just before the submit we update the text in the <span> for whichever line item is being updated:

opener.document.getElementById("trainDate01").innerHTML = updateDateTime;

Really, that's all there is to it. Do a quick computation to get a value for updateDateTime (using JavaScript or even @Now in a computed text area in your code) and that's all you have to do. It's not permanent, but it feels permanent to the user. Refresh the browser and you'll lose it BUT, by that time the WebQuerySave agent will have updated the document so the same value will show up in the same place when the document is reloaded.

Best of all, with half a dozen of us hitting the same form over and over again at the same time, we can't make it cause a replication conflict. A very satisfying solution, if I may say so.

Comments :v

1. Mike Kinder07/05/2010 12:30:41 PM
Homepage: http://www.acadiasolutions.com


Hey Scott,

I read this with great interest as I have been in a position where this was necessary before. However, we solved it a bit differently.

Mind you, I was using a tool I wrote in the 4.6x days that managed record locking for applications. So we wanted to stop users from editing a document that was being edited - on the web. With a simple bit of @Formula and the tool I wrote we were able to accomplish this quite well.

Essentially what happed was, when a user tried to switch a document to edit mode on the web (whether directly by the URL or using a provided button) code ran that checked to see if the document was locked. If it was, we layered a div over the entire screen that told the user it was locked and could not be edited. Then with an auto refresh meta tag we sent them back to a read only version of the document 5-10 seconds later.

With the div overlaying the whole document they could not change any values nor save the changes, thus no harm in letting it open in edit mode. Also, the message told them who had the record checked out/locked and when they locked it. So if it had been some time they could contact that user and see if they could "unlock" it by saving and getting out of the document.

So we, in one solution, came up with effective record locking for the web and a way to control rep/save conflicts.

But this solution is a good one too, just wanted to mention that there was a way to, sort of anyway, "get state" of a domino document on the web.

Mike Kinder




2. Scott Good07/05/2010 02:11:16 PM
Homepage: http://www.scottgood.com


Great idea!




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :cry: :-\ :huh: ;-) :cool: :grin: :emb: :laugh: :-p :lips: :-( :rolleyes: :-o :-D :angry: :-x
bold italic underline Strikethrough





Remember me    

Disclaimer & Copyright
Monthly Archive
Contact me...
Racing sponsors and such...

Thank you sponsors!

GABlogLogo.jpg

GOODAero

GOODAero specializes in building aerodynamic products for racing cars. Our first product, the GOODAero Raptor wing is available at a surprisingly reasonable price (under a grand) for a full carbon, full-sized, racing wing. Check it out.


Infinite Fiberworks Co, a great source for high-quality Porsche fiberglass parts

Infinite Fiberworks Co.

If you are looking for fiberglass for Porsches, IFC is the place to go. I have used parts from most of the major suppliers and IFC's are easily the highest quality and the most reasonably-priced. Contact Mike at Infinite Fiberworks for more information.

Located in Racine, OH (so far Southeast they're almost in West Virginia), IFC's goal is to be The Best. Give 'em a try.


Bent or ugly wheels? Call Wheel Medic!

Wheel Medic & The Round House

Whether you need to repair, repaint, refinish or just replace your wheels, the guys at Wheel Medic/Round House can get you back on the road in no time!

Wheel Medic, Inc is a family-owned company which specializes in the repair and restoration of aluminum wheels.

The Round House was founded to service Wheel Medic's clients looking for more than just repair work...from custom wheel colors to high-end wheel applications and body kits, the Round House is there to serve the discriminating automotive enthusiast.


Used Porsche parts, great prices!

A Part Above

Looking for used parts for 944s, 924s, 968s or other late-model water-cooled Porsches? Contact John at A Part Above.

Located in Strongsville, OH (20 miles south of Cleveland) their goal is to provide top quality parts and services. I can tell you, John is great to work with and the prices? Very hard to beat.


SMRT Motorsports wants you!

SMRT (that's short for Skid Mark Racing Team), a very-

loosely organized band of fun-loving friends who enjoy auto racing (heck, cars in general), and the occasional adult beverage, wants you to be a part of our team.

Go here to find cool T-shirts, sweatshirts, caps and mugs with the SMRT team logo.

The BlogRoll
Lotus Domino ND6 RSS News Feed RSS Comments Feed Geo URL RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF BlogSphere
Calendar
February 2012
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
By Category
What I do for a living


I am the President of Teamwork Solutions a long-time Lotus, now IBM, Premier Partner.

With offices in Columbus and Cincinnati, Ohio, we specialize in custom application development for IBM Lotus Notes, Domino, and related technologies. Our software product, ProcessIt! (see below), is quite possibly the world's best, most powerful and easiest-to-use workflow tool for Notes and the web.

Our clients are some of the world's largest corporations along with others that aren't so big.

We do excellent work, quickly, and often on a fixed-fee basis. We'd love to talk to you about your next project.




I am a Contributing Author to Lotus Advisor Magazine, with more than 40 articles under my belt.

I've written how-to series (serieses?) on LotusScript, JavaScript, Cascading Style Sheets (CSS), and now, AJAX (Asynchronous JavaScript and XML), as well as a bit on miscellaneous web development topics.


TheView.jpg

I also write for The View as of the July/August issue where I showed how to take an ugly Notes applications and make it beautiful with just a few minutes' (careful) work.



I am the chief architect and one of two primary developers for what many consider the best all-around workflow tool for Notes/Domino, anywhere, regardless of price.

It's called ProcessIt!, and you can read all about it at www.notesworkflow.com but the bottom line is this: ProcessIt! is fast and easy to learn, extremely powerful, and can be used by mortals. Even--dare I say it?--common users.

You can spend a lot more on a workflow tool but you won't be able to do a lot more for all the extra money.

Don't believe me? Download and try it for free for 60 days.



GTSLogoSm.gif
Copyright Porsche and NASA...not me!

I race a Porsche 944 S2 in National Auto Sport Assocation events and am the 2008 National Champion in NASA's GTS2 class.

Blame this event, a few years ago, for starting that particular money drain all over again.

In support of my habit, I am the NASA Great Lakes Region's GTS (German Touring Series) Director.

I'm also a Nationally-Certified Instructor for the Porsche Club of America and am in charge of classroom sessions for the Mid-Ohio region when we are doing high performance driving events.

In a prior racing life, I was the Midwestern Regional Formula Atlantic Champion and, in 1991, the Ohio Vally Region of SCCA's Regional Driver of the Year (but that, alas, went away when my credit cards let go of the rope!).




I'm writing a book...or at least trying to.

It's murder mystery in which, not too surprisingly, the main character runs a small software company and races cars for fun. Oh yeah, and lives near where I do.

Just where do they come up with these crazy ideas?

Facebook