Trouble closing window

I am having trouble closing a form after saving with LS, how can I perform these steps. I have tried both Call uidoc.Close and Call doc.close. Neither works.

Call doc.Save(True,True)
Call uidoc.Close
Else
Msgbox "This request was already recevied and is being processed."
End If
I want to do the equivalent of the code below which closes the form and takes them back to their inbox. Essesntially closes two windows.

@PostedCommand([FileSave]);@PostedCommand([FileCloseWindow])
jforget1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

madheeswarCommented:
where did u placed this code? and can we see the full code? and any Form events u r placing this code?

jforget1Author Commented:
Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim ws As New notesuiworkspace
      Dim emaildoc As NotesDocument
      Dim Item As NotesItem
      Dim rtitem As NotesRichTextItem
      'Dim sNamesArr(1)As String
      Dim sNamesArrB(1)As String
      Set doc = ws.currentDocument.Document
      Set db = session.CurrentDatabase
      On Error Resume Next
      If doc.submit_flag(0) <> "done" Then
            Set emaildoc = db.CreateDocument
            emaildoc.form = "vap_submit_tracer" 'Form name of Letter
            emaildoc.sendto = doc.approver(0)
            sNamesArrB(0) = doc.md_name(0)
            sNamesArrB(1) = doc.om_name(0)
            emaildoc.CopyTo = sNamesArrB
      '      emaildoc.BlindCopyTo = doc.bcc
            emaildoc.Principal = "Field Technology"
            emaildoc.Subject = "VAP Removal Request has been submitted for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"                  
            Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
            Call rtitem.AppendDocLink(doc, "")
            Call emaildoc.Send(True)
            doc.status = "Submitted"
            doc.submit_flag = "done"    'field name for flag
            Msgbox  "Your request has been received and is being processed."
            Call doc.Save(True,True)
            Call doc.Close
      Else       
            Msgbox "This request was already recevied and is being processed."
      End If
End Sub


No other events on close.
madheeswarCommented:
Try this:
Sub Click(Source As Button)
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim ws As New notesuiworkspace
     Dim emaildoc As NotesDocument
     Dim Item As NotesItem
     Dim rtitem As NotesRichTextItem
     'Dim sNamesArr(1)As String
     Dim sNamesArrB(1)As String
     Set doc = ws.currentDocument.Document
     Set db = session.CurrentDatabase
     On Error Resume Next
     If doc.submit_flag(0) <> "done" Then
 Call doc.Save(True,True)
          Set emaildoc = db.CreateDocument
          emaildoc.form = "vap_submit_tracer" 'Form name of Letter
          emaildoc.sendto = doc.approver(0)
          sNamesArrB(0) = doc.md_name(0)
          sNamesArrB(1) = doc.om_name(0)
          emaildoc.CopyTo = sNamesArrB
     '     emaildoc.BlindCopyTo = doc.bcc
          emaildoc.Principal = "Field Technology"
          emaildoc.Subject = "VAP Removal Request has been submitted for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"              
          Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
          Call rtitem.AppendDocLink(doc, "")
          Call emaildoc.Send(True)
          doc.status = "Submitted"
          doc.submit_flag = "done"    'field name for flag
          Msgbox  "Your request has been received and is being processed."
       '   Call doc.Save(True,True)
          Call doc.Close
     Else      
          Msgbox "This request was already recevied and is being processed."
     End If
End Sub


Is there any error msgs it is giving? Try to debug the code using Lotus Script debugger and findout in which line it is skipping.
Are u getting msgbox: Your request has been received and is being processed." ?
and did u got the email?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

madheeswarCommented:
hey and make that call doc.close to

call uidoc.close(true)

and add set uidoc=ws.currentdocument

and instead of call doc.save, use call uidoc.save(true)
jforget1Author Commented:
Thiink I almost have it, it gives the alert and saves the doc, it closes but it only does after it asks me if I want to save the doc then closes. I have tried adding Call uidoc.save(true) and (true,true) but it said Wrong Number of arguments.
madheeswarCommented:
use this code and test:
Sub Click(Source As Button)
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim ws As New notesuiworkspace
     Dim emaildoc As NotesDocument
     Dim Item As NotesItem
     Dim rtitem As NotesRichTextItem
     'Dim sNamesArr(1)As String
     Dim sNamesArrB(1)As String
set uidoc=ws.currentDocument
     Set doc = ws.currentDocument.Document
     Set db = session.CurrentDatabase
     On Error Resume Next
     If doc.submit_flag(0) <> "done" Then
 Call doc.Save(True,True) 'Saving the Current document.
          Set emaildoc = db.CreateDocument
          emaildoc.form = "vap_submit_tracer" 'Form name of Letter
          emaildoc.sendto = doc.approver(0)
          sNamesArrB(0) = doc.md_name(0)
          sNamesArrB(1) = doc.om_name(0)
          emaildoc.CopyTo = sNamesArrB
     '     emaildoc.BlindCopyTo = doc.bcc
          emaildoc.Principal = "Field Technology"
          emaildoc.Subject = "VAP Removal Request has been submitted for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"              
          Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
          Call rtitem.AppendDocLink(doc, "")
          Call emaildoc.Send(True)
          doc.status = "Submitted"
          doc.submit_flag = "done"    'field name for flag
          Msgbox  "Your request has been received and is being processed."
         Call doc.Save(True,True)
          Call doc.Close
     Else      
          Msgbox "This request was already recevied and is being processed."
     End If
End Sub
jforget1Author Commented:
I ran it through debugger and it hits all the steps and give the proper alert, it does not close the window though and when I escape it still asks me to save.
madheeswarCommented:
try with
call uidoc.close(true) instead of call doc.close

this should work
jforget1Author Commented:
It now closes but it is still prompting me to save first.
madheeswarCommented:
then u should be having SaveOptions field?

or create one Saveoptions field and make the defualt value "0".
and in your code add doc.saveoptions="1"

and u can try with call doc.save(true,true) with uidoc for saving
and try doc and uidoc for closing.. u can play with them and u can know easily.
and is it in Std application or mail database?
if it is in Mail db, then u may get into problem as there are some problems validating..

jforget1Author Commented:
I have a Saveoptions field but it is set to 1
I will play around with that and the doc.uidoc issues.
THis is a std db
jforget1Author Commented:
Still trying to figure this one out, here is the end of the latest attempt. It is closing without prompting but I am getting an "Cannot locate default form" error.

            emaildoc.Principal = "Field Technology"
            emaildoc.Subject = "VAP Removal Request has been submitted for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"              
            Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
            Call rtitem.AppendDocLink(doc, "")
            Call emaildoc.Send(True)
            doc.status = "Submitted"
            doc.submit_flag = "done" 'field name for flag
            Msgbox "Your request has been received and is being processed."
            Call doc.save(True,False)
            doc.saveoptions = "0"
            Call uidoc.close(True)
      Else      
            Msgbox "This request was already recevied and is being processed."
      End If
End Sub
madheeswarCommented:
I have tested this and its working.
Sub Click(Source As Button)
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim ws As New notesuiworkspace
     Dim emaildoc As NotesDocument
     Dim Item As NotesItem
     Dim rtitem As NotesRichTextItem
     'Dim sNamesArr(1)As String
     Dim sNamesArrB(1)As String
set uidoc=ws.currentDocument
     Set doc = ws.currentDocument.Document
     Set db = session.CurrentDatabase
     On Error Resume Next
     If doc.submit_flag(0) <> "done" Then
 'Call doc.Save(True,True) 'Saving the Current document.
          Set emaildoc = db.CreateDocument
          emaildoc.form = "vap_submit_tracer" 'Form name of Letter
          emaildoc.sendto = doc.approver(0)
          sNamesArrB(0) = doc.md_name(0)
          sNamesArrB(1) = doc.om_name(0)
          emaildoc.CopyTo = sNamesArrB
     '     emaildoc.BlindCopyTo = doc.bcc
          emaildoc.Principal = "Field Technology"
          emaildoc.Subject = "VAP Removal Request has been submitted for " + doc.user_adjusted(0) + doc.alt_name(0) +  "!"              
          Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
          Call rtitem.AppendDocLink(doc, "")
          Call emaildoc.Send(True)
          doc.status = "Submitted"
          doc.submit_flag = "done"    'field name for flag
          Msgbox  "Your request has been received and is being processed."
       Call uidoc.save
      Call uidoc.Close
     Else      
          Msgbox "This request was already recevied and is being processed."
     End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jforget1Author Commented:
I copied your script exactly and it does not ask me to save, but it does not save the doc at all. There is nothing in the view after it closes. I have reopened and refreshed.

Joe
madheeswarCommented:
Since the Saveoptions field u have is set to "0".. make it to "1".

or remove that Saveoptions field and test.
jforget1Author Commented:
Thanks so much for helping with this one.
madheeswarCommented:
no problem.. and thanks for the points..

And I apologise for dragging this so far... I should have tested before...blindly I gave solutions...no time to test. looks like I am over confident..

jforget1Author Commented:
Hey no problem, it all worked out.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.