[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unable to save document on web

Posted on 2006-06-06
22
Medium Priority
?
419 Views
Last Modified: 2013-12-18
Most learned experts,

I am once again at a quandry. I've done a search on similar postings and tried to execute some of the suggestions without success. I seem to be unable to save a document on the web. I am on Domino 6.5. When I click on the Save button it appears to submit the doc, I even get a message that the document has been submitted but if I look for it on the Notes client side, you don't see it even if the view is refreshed. Each required field has an input validation formula that checks and produces appropriate messages depending on whether the client is Notes or Web. Do I even need to check for the web side of things if I am doing the validation in the OnSubmit event? Did I go "overboard" on the web side validation? I'm not a JS expert, just put together items from various sites for the web side validation. Please let me know if you need any more information. This question, unfortunately, has a higher priority than the others. Many, many thanks.

Save button code: @Command([FileSave]); @Command([FileCloseWindow])

$$Return field (text, computed for display) code:
db:=@ReplaceSubstring(@ReplaceSubstring(@Subset(@DbName; -1);" ";"+");"\\";"/");
existingdoclink:="<hr><font size=3 face=arial><a href=/"+db+"/vPMRSystem/"+@Text(@DocumentUniqueID )+"?OpenDocument>" + "Previous Document" + "</a>&nbsp&nbsp&nbsp";
confirmmsg := "<h3>" + "Thank you. Your PMR has been submitted" + "</h3>";
bkgd := "<body bgcolor=\"" + "#ffffff" + "\"+ >";
OkMsg :=  bkgd + confirmmsg + existingdoclink;
OkMsg

OnSubmit code:
var f = document.forms[0];
if (f.pmr_status.value == "Open" && f.pmr_open_notify.value == "No")
{ //open - pmr open validations
// Check Description field
  if (f.pmr_desc.value == "" || f.pmr_desc.value == "null")
{
  msg = "Please enter a description of the problem in the Brief Description field and click on the Add button.";
    alert (msg);
  f.pmr_desc.focus();
return false;
}
  // Check that one of the Type checkboxes has been selected
var cb = false;   // assume none chosen until specified otherwise
for (i = 0; i < f.pmr_type.length; i ++) {
if (f.pmr_type[i].checked) {
cb = true;   // as long as one is chosen this gets set true
}
}
if (cb == false) {
alert ("Please select either Hardware, OS, Application, Connectivity or Other for the Type field.");
f.pmr_type[0].focus();
return false;
}
//Check if Type=Other that explanation field is filled in
if (f.pmr_type.value == "Other" && f.pmr_type_other.value == "")
{
  msg = "Please explain what the other type of problem is for this PMR in the If Other, please explain: field.";
    alert (msg);
  f.pmr_type_other.focus();
return false;
}
//Check that at least one system is selected in dialog list
var sysSelected = 0;
var i;
for (i = 0;  i < f.pmr_systems.length;  i++)
{
if (f.pmr_systems.options[i].selected)
{
sysSelected++;
}
}
if (sysSelected < 1)
{
alert("Please select at least one system in the System(s) Affected field.");
f.pmr_systems.focus();
return (false);
}
// Now check to see that the severity has been selected
var rb = false;   // assume none chosen until specified otherwise
var j
for (j = 0; j < f.pmr_severity.length; j ++) {
if (f.pmr_severity[j].checked) {
rb = true;   // as long as one is chosen this gets set true
}
}
if (rb == false) {
alert ("Please select the severity of this PMR in the Severity field.");
f.pmr_severity[0].focus();
return false;
}
} //close - pmr open validations

WebQuerySave event: runs an agent called submit
submit agent code:
      Dim session As NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim notifydoc As notesdocument
      Dim recipients (1 To 4) As String
      Dim subject As NotesItem
      Dim body1 As Variant, body2 As Variant, body3 As Variant, body4 As Variant
      Dim systemsaffected As String
      Dim rtitem As NotesRichTextItem
      Dim updatehist As String
      
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      Set doc = session.DocumentContext
      Set notifydoc = New notesdocument (db)
      recipients(1) = doc.pmr_createby(0)
      recipients(2) = doc.pmr_ownerofsys(0)
      recipients(3) = doc.pmr_respmgr
      recipients(4) = doc.pmr_resourceassigned
      systemsaffected = doc.pmr_systems(0)
      
      If doc.pmr_status = "Open" And doc.pmr_open_notify="No" Then
            maildoc.Form = "Memo"
            maildoc.Subject = "PMR# " + doc.pmr_ref(0) + " has been opened"
            body1 = "Please click on the link below to review this PMR."
            body2 = "Opened by: " & session.CommonUserName & " on " & Date$
            body3 = "Systems affected: " & systemsaffected
            body4 = "Description of problem: " + doc.pmr_desc(0)
            
            Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
            Call rtitem.AppendText ( body1 )
            Call rtitem.AddNewLine( 2 )
            Call rtitem.AppendText ( body2 )
            Call rtitem.AddNewLine( 1 )
            Call rtitem.AppendText ( body3 )
            Call rtitem.AddNewLine( 1 )
            Call rtitem.AppendText ( body4 )
            Call rtitem.AddNewLine( 2 )
            Call rtitem.AppendText ( "Click on the link to view the PMR: ")
            Call rtitem.AppendDocLink( doc, db.Title )
            Call maildoc.Send(False, recipients)
            Call maildoc.Send(False, "Jade Quek/Los Angeles/IBM")
            
            doc.pmr_open_notify(0) = "Yes"
            updatehist = "[" & session.CommonUserName & " on " & Cstr(Now) & "] - PMR Opened"
            doc.pmr_log = Chr(10) & doc.pmr_log & Chr(10) & updatehist
            Call doc.Save( True, True )
            
      End If

0
Comment
Question by:notesrookie
  • 10
  • 7
  • 5
22 Comments
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 1600 total points
ID: 16847693
Did you check all logs? Log.nsf for errors, domlog.nsf or the HTTP log files for a trace?
Do you have a view in your database that shows ALL documents, ordered by Form, or Created, or Modified, so you can see what documents are in the database?
Do you have sufficient rights to see all documents?
Do you know whether the WebQuerySave agent ran? Did you check the agent's log?

What if you disable the JavaScript functions?

Did you look in the right database, and not in an outdated replica (sorry for asking...)?

Ah, might be very fatal: it is forbidden to call doc.Save from within a WebQuerySave agent.
0
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 400 total points
ID: 16848134
Just another note..

usually when you want to do javascript validations, then you have to put the onsave= javascript.validatethis() in the form header.  
<Form id="thisform" onsave="javascript.validatethis()">
  form stuff
/<form>

then the button has to do another function that gathers the results of the validate this and allow the submit or display the error and ask the user to complete missing stuff.   TwoGuysFromRolla.com  very good place for javascript tutorials.
0
 

Author Comment

by:notesrookie
ID: 16848235
There appears to be a type mismatch in the Submit agent but it did save it. So I'll run through the submit agent to see why it failed. I was testing using another form so I had to modify the form name to have it show up (my bad!). However, when the form is composed on the web and saved the authors form only records my name (as the creator), the server name and roles. The system owner and manager information never make it to the computed for display authors field. Does that need to be added to the authors field as part of the submit agent? But my information does not appear to be caching. When I refresh I get the error that the page has expired. How do I get around that?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:notesrookie
ID: 16848272
marilyng - forgive my ignorance but you said ...

usually when you want to do javascript validations, then you have to put the onsave= javascript.validatethis() in the form header.  
line 1: <Form id="thisform" onsave="javascript.validatethis()">
  form stuff
line 3: /<form>

Do I place line line 1: at the very top of my form and line 3: at the very bottom, both as passthru HTML? Or in JSHeader? Thank you.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1600 total points
ID: 16849894
The easiest way to find out where your agent stopped is to put some error catching in it.

At the start...

        On Error Goto onerror

And just before the End Sub...

    exitsub:
        Exit Sub

    onerror:
        MessageBox "Error " & Error & " (" & Err & ") on line " & Erl
        Resume exitsub

The MessageBox will put a message in the server's log.nsf database. You would need to have access to that database of course..

If you don't have access, or you want a different solution, you can use the NotesLog methods. An example:

    exitsub:
        Exit Sub

    onerror:
        Dim currentLog As New NotesLog( "Checkup Agent" )
        Call currentLog.OpenMailLog( "Notesrookie/ABCD",  "Log for WebQuerySave" )
        Call currentLog.LogAction( "Error " & Error & " (" & Err & ") on line " & Erl)
        Call currentLog.Close
        Resume exitsub

The message will be mailed to you.
0
 

Author Comment

by:notesrookie
ID: 16853234
Cool, sjef. Let me try that.
0
 

Author Comment

by:notesrookie
ID: 16854295
sjef - I wasn't able to see anything in the notes log. I'll change the messagebox to a print statement.

marilyng - I added your suggestion but got an error on page in the status bar below the browser.

Perhaps if I got an understanding of the sequence of events that would help. Please correct me if I'm wrong.

All required fields have validation if the client is of type web
The user clicks onthe Save action button (not a button within the form)
The OnSubmit event fires and validates required fields
The WebQuerySave runs my "Submit" agent
A new window opens with "Thank you for your .... has been submitted" message

Don't know what happened but my $$Return field is no longer functioning. I don't get the thank you message any more.
0
 

Author Comment

by:notesrookie
ID: 16854427
Another question I had is that when I hit the Back button, I get an error saying that the page has expired. How do I cache my information so that I can go back to it. Thanks.
0
 

Author Comment

by:notesrookie
ID: 16857098
I feel like I don't know anything when my brain goes around in circles. I decided to start all over and luckily I had used a copy of the form to do the web testing with. I started all over and left out the JS validation in the OnSubmit event. I chased all the errors out of my Submit agent and the $$Return field is working again. The document is actually saving. However, if a required field is not filled in and you click on the Save action button, the input validation formula kicks in and produces a page with a message. But when I click on the back button, "page has expired". So that is still happening. Would someone please let me know how I can go about caching the form in the state it was in before the Save button was clicked. Thank you again.

Sample input validation formula:
msg:="<b><hr><font size=3 face=arial>The Brief Description field is a mandatory field. Please click on Back to return to the document.</b>";
msg2:="The Brief Description field is a mandatory field.";
@If(
pmr_desc="" & @ClientType="Web"; @Failure(msg);
pmr_desc="" & @ClientType="Notes"; @Failure(msg2);
@Success)
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 1600 total points
ID: 16859718
> I'll change the messagebox to a print statement.
Not good: in a web agent, Print goes to the web page, and Messagebox to the Notes log. I suppose the Print is also the reason why the $$Return stopped working.
If nothing in the log Then
    Conclusion "MessageBox not done"
End If

> an understanding of the sequence of events
The web browser and the Domino server play completely separate roles. When the user clicks Save, the onSubmit in JavaScript fires. That code runs until it returns True or False, or upto the first error! If the result is True or an error occurred, the data is posted to the Domino server for processing there. If False, the user stays in the browser and nothing is sent out.

About validation: try to make it work without validation on the Domino server. That's where the JavaScript comes in. Begin with validation on one field, test it and make it work, and then implement the others.

In the onSubmit:

    return validateFields();

And in the JSHeader:
    var form;

    function validateFields() {
        form= document.forms[0];
        return validateField("pmr_desc", "Please enter a description of the problem in the Brief Description field and click on the Add button.");
        // return validateField("pmr_desc", ...) && validateField("pmr_type", ...); // for more fields
    }

function validateField(fld, msg) {
    if(checkField(fld)) {
        alert(msg);
        return false;
    }
    return true;
}

function checkField(fld) {
    var f= form.elements[fld];
    var i, err;
   
    if(!f)
        return true;
    err= false;
    if(f.type) {
        switch(f.type) {
        case "password":
        case "text":
        case "textarea":
            if(typeof(f.value)=='number') {
                if(f.value==0)
                    err= true;
            } else {
                f.value= f.value.replace(/^ */,'');
                f.value= f.value.replace(/ *$/,'');
                f.value= f.value.replace(/   */,' ');
                if(f.value=="")
                    err= true;    
            }
            break;
        case "select-multiple":
        case "select-one":
            if(f.selectedIndex<0)
                err= true;
            break;
        default:
            alert('Unknown '+v+'('+f.type+')');
        }
    } else {
        switch(f[0].type) {
        case "radio":
        case "checkbox":
            err= true;
            for(i= 0; i<f.length; i++) {
                if(f[i].checked) {
                    err= false;
                    break;
                }
            }
            f= f[0];
            break;
        default:
            alert('Unknown '+v+'<'+f[0].type+'>');
        }
    }
    if(err) {
        f.focus();
        return false;
    }
    return true;
}

The checkField function I copied from some application, I don't know if it is exactly right here. It will test for any field type whether it has a value or not. It even trims text fields to check whether they are empty or not. I hope this will work for you...
0
 

Author Comment

by:notesrookie
ID: 16864972
OK, sjef. I'll implement your suggestions. I think that was my disconnect. My document is saved but there is no email being send out. Thanks.
0
 

Author Comment

by:notesrookie
ID: 16874546
I was unable to use your checkField function as I was getting error on the page. However, I did finally get it to work by  reusing my original form with the onSubmit and WebQuerySave events (not really sure why it works now). I also figured out how to stop my document from expiring. I created a field, text, computed for display, at the very top with the code - @SetHTTPHeader("Expires"; @Adjust(@Now([ServerTime]); 0; 0; 0; 0; 5; 0)) - so my cache expires in 5 minutes instead of immediately. Thanks for all your help.
0
 

Author Comment

by:notesrookie
ID: 16874579
Most of the points for sjef because he told me where i could go look for my errors which got me to put in messagebox statements so I could see where the code blew up and got me thinking (doesn't hurt so much any more :D). Points to marilyng because she sent me to a website which had great JS validation scripts.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16876163
:) Thanks!
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16877090
In order to deserve points, I need to post the right link... duh..www.4guysfromrolla.com

2, 4, guys.. hey, they're all from rolla :)  Yes, great tutorials, too.   Their validation logic is quite good.

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16877681
> Their validation logic is quite good.
Now what's that supposed to mean?

;)
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16877774
Web form validation events and explanation of the event triggers.
0
 

Author Comment

by:notesrookie
ID: 16879481
No worries, marilyng. I was able to find it by doing a search and there they were. Sometimes I have moments of clarity! :)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16880043
LOL

I read it as:
    THEIR validation logic is quite good...
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16880881
Sorry, if you're making a joke about something I wrote, I am not following it.  I am sincere when I say I like their website and their tutorials and explanations of javascript event logic.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16881164
... as opposed to mine...

Oh, never mind. I'll visit that site, maybe I they have a great universal field validation function, to replace mine.
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16881331
Ah, no offense intended.

If I recall, they have a .js validation file that is one of those collection of common validation functions.. is email address, is phone, is web address, and so on.

I've added to it since I grabbed it, and use it in all my website forms. :)
0

Featured Post

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.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

873 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