I have a workflow application that user was able to save it twice. I do use ‘SaveOptions’ to prevent it from saving if it does not pass validation. I am thinking about using the following logic in my webquerysave agent: 1. use an application generated id to verify the save document does not exist. 2. if it does and the UNID is the same then save it. If it does not, it is a duplicate and error.
But is there an other approach like using Javascript to prevent it from submiting it in the first place?
Subject: How to prevent saving document twice in the web?
Why are they able to save twice? Slow response time of the web?? do you use a redirect after save?
Subject: How to prevent saving document twice in the web?
Hello Raymond,
You can do it with Javascript like this:
First declare a variable that holds false if the document is not submitted yet
and true if the document has been submitted.
Adjust the submit button, so a javascript function is called. This function
checks if the document has been saved and if so will not save it again.
var docSubmitted = false;
function doSubmit(){
// You can add field validations here
if(docSubmitted == true) {
alert("You can only submit this document once, please wait");
} else {
docSubmitted=true
document.forms[0].submit();
}
}
Rene
Subject: RE: How to prevent saving document twice in the web?
I have tried your suggestion without success. ( I have put the code in a library then call the function on the submit event. Maybe I have to do something else?).So I developed my own solution like this:
In Domino, we can disable a button by JavaScript, using disabled property of the button. However, even when the button is grey out, clicking on it still submits the document.
I has to use an extra button which looks the similar to the Submit button and when this extra is clicked , it does nothing.
In the sample, there are 2 Submit buttons. The extra button is placed next to the original button
Submit Button placed here Extra Submit Button placed here
When the original Submit button is clicked, it should call, among other things, an extra function.
disableButton(‘OK’);
function disableButton(id) {
var elem = document.getElementById(id);
var elem2 = document.getElementById('OK2');
if (elem) {
elem.disabled = true;
elem.style.display = 'none';
elem2.style.display='block';
}
}
Hope this helps.