Doclink to other document

Hello All,
I always have interesting things going on......
Here I'm creating a document that when a submit button is pressed, it takes numerous fields off the document and generates a different document using a different form and then sends an automated email contacting the receiver of the other generated document that one has been created and is pending his review.  In the email Iwant to have a doclink to the new background document created, not the main document.  
Let me give you some business background on this function to clarify.
The main form is a detailed job run documnet that outlines everything you need to know about a particular job.  In this form there are fields outining file specs.  The auto created form creates a file form and sends it to a person that is reponsible for creating the file specs.  so the email needs to doclink to new file form not the main.
hope this makes sense.
Thanks !
Paul
LVL 4
pratiganAsked:
Who is Participating?
 
p_parthaConnect With a Mentor Commented:
I meant declaration..

go to form global and there put this line:

  Dim db As notesdatabase

or u can try this:

function processmail(doclink as notesdocument)
dim session as new notessession
dim db as notesdatabase
set db = session.currentdatabase
Dim maildoc As notesdocument
    Set maildoc = db.createdocument
    Dim rtitem As NotesRichTextItem
    Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
    maildoc.form="memo"
    maildoc.sendto = "Paul R Ratigan/CIV/CSC"
Call rtitem.AppendDocLink ( doclink, "doclink" )
maildoc.subject = "test"
    Call maildoc.send(False)
end function
0
 
p_parthaCommented:
You have to use appenddoclink method of notesrichtextitem class
  Call rtitem.AppendDocLink( doc, db.Title )

doc can be any document(in your case the document created on teh fly)

Partha
0
 
pratiganAuthor Commented:
Hello Partha,
HOw do I identify my document on the fly ??
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
p_parthaCommented:
how are you creating the documnet , it should be in webquerysave or querysave(if it's notes client). In that you will anyways have the handle to the new documnet, use that in your mail memo code

Partha
0
 
pratiganAuthor Commented:
here is the code that creates the "on the fly form"
Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Dim ss As New notessession
      Dim db As notesdatabase
      Dim ws As New NotesUIWorkspace
      Dim uidoc As notesuidocument
      Dim doc As notesdocument
      Dim backendDoc As NotesDocument
      Set db = ss.CurrentDatabase
      Set uidoc = ws.CurrentDocument
      Set backendDoc = uidoc.Document
      Dim success As Variant
      Dim freqWrd As Variant
      Dim inputbx As Variant
      '************************************************************
      '   Flags set to New .... Create new request forms
      '************************************************************
      If (backendDoc.prod_cklst_mobius_flag(0) = "New" And backendDoc.rpt1(0) <> "" And backendDoc.Status(0) = "Submitted") Then       
            Set doc = db.CreateDocument
            doc.Form = "ORRform"
            doc.ORdate_req_prod = backendDoc.Prod_Dt(0)
            doc.ORrequest = backendDoc.DisplayAuthor(0)
            doc.ORtype = backendDoc.Prod_cklst_mobius_flag(0)
            doc.ORjob_nme = backendDoc.jclmember(0)
            doc.ORappl = backendDoc.Subsystem(0)
            doc.ORdesc = backendDoc.rpt1(0)
            doc.ORrpt = backendDoc.rpt1_rpt_ID(0)
            doc.ORwriter = backendDoc.rpt1_wrtr_nam(0)
            doc.ORfreq = Mid(backendDoc.jclmember(0), 4, 1)
            freqWrd = Mid(backendDoc.jclmember(0), 4, 1)
            
            Dim view As NotesView
            Set view= db.getview("(ORreq)")
            Set vdoc= view.getfirstdocument
            If vdoc Is Nothing Then
                  doc.ORreq= 1
            Else
                  doc.ORreq= vdoc.ORreq(0) + 1
            End If
            
            If freqWrd = "D" Then
                  doc.ORfreq = "Daily"
            Elseif freqWrd = "W" Then
                  doc.ORfreq = "Weekly"
            Elseif freqWrd = "M" Then
                  doc.ORfreq = "Monthly"
            End If
            success = doc.ComputeWithForm( False, False )
            
            If success Then
                  Call doc.Save( True, False )
                  backendDoc.prod_cklst_mobius_flag = ""
                  Call backendDoc.Save(True,False)
            End If
      End If      
0
 
p_parthaCommented:
doc is the new document, send this document as parameter to the mail generation functoin..or paste that function , i will try to help you out

Partha
0
 
pratiganAuthor Commented:
The mail function is initiated when the submit button is pressed.
Prod_cklst_mobius_flag != "";
@MailSend("Paul R Ratigan/CIV/CSC"; "";"";"Mobius Rpt Request has been processed and is Pending your Review.";"";"Mobius Request Doc Link =>  "; [IncludeDoclink]);"");
0
 
p_parthaCommented:
@mailsend as far as i know you cannot use any other document link apart from ur current document, so ideally you have to put your mailsend code in lotusscript querysave itself.

something in this lines:

declare your doc globally and change your if condition to

 If success Then
              Call doc.Save( True, False )
call Processmail(doc)


              backendDoc.prod_cklst_mobius_flag = ""
              Call backendDoc.Save(True,False)
         End If


Add a new function

function processmail(doclink as notesdocument)
Dim maildoc As notesdocument
      Set maildoc = db.createdocument
      Dim rtitem As NotesRichTextItem
      Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
      maildoc.form="memo"
      maildoc.sendto = "Paul R Ratigan/CIV/CSC"
Call rtitem.AppendDocLink ( doclink, "doclink" )
maildoc.subject = "test"
      Call maildoc.send(False)
end function
0
 
pratiganAuthor Commented:
Helo Partha,
That's excellent.  I'm coding that in right now and I'll be testing it this morning.  I'll let you know how I make out.
Thank You !!!
paul
0
 
pratiganAuthor Commented:
Hello Partha,
I'm gettting an error:  Variant does not contain an object on line:
      Set maildoc = db.createdocument
0
 
p_parthaCommented:
Hey paul
Make sure db is pointing to the current database, if it is then declare it globally

Partha
0
 
pratiganAuthor Commented:
     Set db = ss.CurrentDatabase
This is setup already in the beginning of the Querysave section.
0
 
pratiganAuthor Commented:
Hello Partha,
Got it working..... Excellent.
Is there a way to have a message before or after the doclink in the body of the email instead of just the actual doclink.  I tried adding this:
      maildoc.body = "Mobius Request Doc Link => "
to the function to put a message indicating the link but when it generated the email, this message appeared but the doclink was no longer there.???
Thanks !

0
 
p_parthaCommented:
Call rtitem.Appendtext ("this is just a test message for paul")

Call rtitem.AppendDocLink ( doclink, "doclink" )

Partha
0
 
pratiganAuthor Commented:
Awesome..... worked like a Charm.  
Thank you Very Much.
I totally Appreciate Your Help !!
0
 
p_parthaCommented:
Thx for the points :)

btw you can even try this:

 Call rtitem.Appendtext ("this is just a test message for paul")
  Call rtitem.AddNewLine( 1 ) ' this is just to add a new line
Call rtitem.AppendDocLink ( doclink, "doclink" )

Partha
0
 
pratiganAuthor Commented:
Excellenet... That helps make the body neater.
Thank you !!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.