Copy button and issue if key not generated

Hi All,

I have a copy button on a view that allows a user to select a doc from the view, copy the fields to the new doc, and creates a key for the doc (not DOCID, a key sequential number). With the number of users that makes copies, it will likely be possible that a seq key could be generated at the same time, resulting in an error for ONE of those users.

This doc that gets created is in the UI, so with one of the docs having a proper seq number, and the other not, how would I be able to eliminate ther errored doc before it even gets created??

The only way I can think to do this, is to save the error doc, use the DOCID to find it again and delete it!

But of course the user will think that they have lost their mind when it does not exist anymore!

Right now, my code generates a message to the error one saying that it cannot create the key number. But the doc is already in the UI?!?!

Is there a way that I can clear the UI without having to save the doc???

Any help or ideas will be appreciated

Mick

Subject: copy button and issue if key not generated

This is a very commonly asked question. Search both forums on sequential numbers, and you will find many, many posts which explain different ways of dealing with this, including some which argue against using sequential numbers at all, in favor of randomly or otherwise-generated numbering.

Subject: RE: copy button and issue if key not generated

Bruce,

I do not have a problem with the sequential numbering! That works fine. The issue is with two users trying to generate the seq number at the same time!! One will create it ok, the other will get an error message. And since the docs are created in the UI, one has all the correct information, and the other one does not. I would like to eliminate the error doc from being launched into the UI at all.

Mick

Subject: RE: copy button and issue if key not generated

Yep, if I go back and read your original post again, I guess that is what you asked!

Depending on what kind of error you’re getting (Notes client-generated dialog vs. error message in field, etc.), you might get away with different tricks. Perhaps putting the following into PostOpen:

@If(@IsError(seqnumfieldname); @Do(FIELD SaveOptions := “0”;

@Prompt([ok]; “Error”; “Error generating document number; please try again.”);

@command([fileclosewindow])); “”)

Or maybe retrieving the seqnum into a variable in LotusScript, testing it for validity, presenting an error message if invalid, and if valid you use NotesUIWorkspace.composedocument to create your new doc and then pop the seqnum into the appropriate field.

The first idea is less work, but the 2nd one stops the doc from ever opening.

Just a couple of ideas. Keep us posted?

Subject: RE: copy button and issue if key not generated

Thanks Bruce,

Those are some good ideas I will try! I will keep everybody posted if I come up with a viable solution.

Thanks again for your responses… much appreciated…

Mick