Solved

Create a Response Doc in Lotus Script

Posted on 1998-12-31
11
715 Views
Last Modified: 2013-12-18
I have the following code:

Sub Exiting(Source As Field)
     Dim W As New NotesUIWorkspace
     Dim UIDoc As NotesUIDocument
     Set UIDoc = W.CurrentDocument
     If (UIDoc.FieldGetText ("Stock") = "Yes") Then
          Call W.ComposeDocument( "", "", "Replacement Sheet" )
     Else
          Messagebox "You can now click the Save & Close Button.", 0, "Continue"
     End If    
End Sub

This code is executed in the main doc when exiting the Stock field. It is SUPPOSE to compose a response doc (which it doesn't do).  The code works if I create a normal doc with the code instead of a response.  Does anyone know what is wrong and how to fix?  

Greetings
0
Comment
Question by:deona123198
  • 5
  • 4
  • 2
11 Comments
 
LVL 1

Expert Comment

by:wrichard
ID: 1117832
I prefer to use the back end lotusscript classes whenever possible.  The code below is a quick pass at solving your problem.  It will generate a response document for the form you are currently in, save the current form and display the new form to the user.

Sub Exiting(Source As Field)
         Dim W As New NotesUIWorkspace
         Dim UIDoc As NotesUIDocument
         Set UIDoc = W.CurrentDocument
         Dim session as new notessession
         dim db as notesdatabase
         set db = session.currentdatabase
         Dim doc as notes document
         dim newdoc as notesdocument
         If (UIDoc.FieldGetText ("Stock") = "Yes") Then
              newdoc = db.createdocument
              newdoc.form = "Replacement Sheet"
              call newdoc.makeresponse(doc)
              call newdoc.save(true, false)
              set uidoc = w.editdocument(true, newdoc)
         Else
              Messagebox "You can now click the Save & Close Button.", 0, "Continue"
         End If      
    End Sub

Hope this helps...
0
 

Author Comment

by:deona123198
ID: 1117833
Sub Exiting(Source As Field)
         Dim W As New NotesUIWorkspace
         Dim UIDoc As NotesUIDocument
         Set UIDoc = W.CurrentDocument
         Dim session as new notessession
         dim db as notesdatabase
         set db = session.currentdatabase
         Dim doc as notesdocument
         dim newdoc as notesdocument
         If (UIDoc.FieldGetText ("Stock") = "Yes") Then
<ERROR IN SCRIPT>  newdoc = db.createdocument          
              newdoc.form = "Replacement Sheet"
              call newdoc.makeresponse(doc)
              call newdoc.save(true, false)
              set uidoc = w.editdocument(true, newdoc)
         Else
              Messagebox "You can now click the Save & Close  Button.", 0, "Continue"
         End If      
    End Sub

I get an error in the script where marked, could anyone please clarify?
0
 

Author Comment

by:deona123198
ID: 1117834
I don't know if the answer is correct, as I get script errors.
Anybody know why?
0
 
LVL 4

Expert Comment

by:stamp
ID: 1117835
Try this:
Sub Exiting(Source As Field)
     Dim W As New NotesUIWorkspace
     Dim session As New NotesSession
     If (W.CurrentDocument.FieldGetText ("Stock") = "Yes") Then
          Dim newdoc As  New NotesDocument( session.CurrentDatabase )          
          newdoc.form = "Replacement Sheet"
          Call newdoc.makeresponse(W.CurrentDocument.Document)
          Call newdoc.save(True, False)
          Set uidoc = W.EditDocument(True, newdoc)
     Else
          Messagebox "You can now click the Save & Close  Button.", 0, "Continue"
     End If        
End Sub
0
 
LVL 4

Expert Comment

by:stamp
ID: 1117836
Sorry. There was still one object not initialized. Try better this:
Sub Exiting(Source As Field)
     Dim W As New NotesUIWorkspace
     Dim UIDoc As NotesUiDocument
     Set UIDoc = W.CurrentDocument
     If (uidoc.FieldGetText ("Stock") = "Yes") Then
          Dim session As New NotesSession
          Dim newdoc As  New NotesDocument( session.CurrentDatabase )          
          newdoc.form = "Replacement Sheet"
          Call newdoc.makeresponse(W.CurrentDocument.Document)
          Call newdoc.save(True, False)
          Set UIDoc = W.EditDocument(True, newdoc)
     Else
          Messagebox "You can now click the Save & Close  Button.", 0, "Continue"
     End If        
End Sub

Remember that your form "Replacement Sheet" has to have "Form type:" set to "Response" to have correct relations.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:deona123198
ID: 1117837
The Response document is set to response, but none of the fields will inherit the values from the main doc. The response doc is set to formulas inherit values from selected doc.  Otherwise the code looks fine...thanks.
How do I get the formulas to inherit values?
Is this due to the code?
0
 
LVL 4

Expert Comment

by:stamp
ID: 1117838
You need two settings:
- "Form type:" set to "Response"
- "Defaults" tab / "On Create:"  set to "Formulas inherit values from selected document"

In the "Default Value" event of every field you want to inherit value from parent set as
formula the name of the field (without quotas).
0
 

Author Comment

by:deona123198
ID: 1117839
All settings is as needed, thanks anyway..
Should the main doc not be saved before the response is created (to inherrit values)?  
If so how?

Regards
0
 
LVL 1

Accepted Solution

by:
wrichard earned 100 total points
ID: 1117840
Since you are using backend classes to create the new document you need to map the fields over that you want to populate in the response doc.  From my first answer the error that you were getting on the line
newdoc = db.createdocument
is because the newdoc needs to be set try this line instead
set newdoc = db.createdocument

then between these 2 lines of code
newdoc.form = "Replacement Sheet"
call newdoc.makeresponse(doc)
map the fileds that you want to inherit values using code similar to this
newdoc.fieldA = doc.fieldA(0)

hope this helps
0
 
LVL 4

Expert Comment

by:stamp
ID: 1117841
After calling "MakeResponse" put this line:
Call W.CurrentDocument.Document.CopyAllItems(newdoc, True )
and assign after this the form item:
newdoc.form = "Replacement Sheet"

0
 

Author Comment

by:deona123198
ID: 1117842
Thanks, problem solved
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IBM Enterprise Integrator - ZID File 1 169
Send email lotus notes / VBA 6 167
I need to install a client Lotus Domino in MAC BOOK AIR 4 75
Domino Website - Redirection 12 50
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now