Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create a Response Doc in Lotus Script

Posted on 1998-12-31
11
721 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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