LS Send e-mail with doclink parent

Please I need your help.  I do not work with LS a lot.

1) The user is in a response form.
2) He sends an e-mail
3) The e-mail should have the link to the parent form not to the response form (which is the actual document the user is in)

Could you provide me with the LS to do this.  I think @SendEmail does not work because the IncludeDocLink includes the current ResponseForm Link.

Many thanks!

I am posting this question with 125 points but I promise 500 for a complete script, because I need it urgently.
LVL 5
ZopiloteAsked:
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:
try this below logic:
Okay have a field in the main document and call it docid.
Make it Text-Computed with a formula @Text(@DocumentUniqueID).  Hide this field.

In the response document have a field called ParentDocumentRef and have it Text-Computed with a formula docid(the field name of the parent doc).

Have the response document docs form property to include the "Formulas inherit values from the selected doc".

After this the subform will have The parent doc unid in the field ParentDocRef field even before its saved.  Use this to access the parent doc.
Thanks to Arun
0
madheeswarCommented:
Then we can have a document unique id with above logic and we can send parent document as link.

Is it Ok for u?

If it is ok, let me know so that I can provide LScript to send emails.
0
madheeswarCommented:
Wait a minute, I will give complete solution in LScript.

No need to use above method.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

madheeswarCommented:
try below code and let me know:
Sub Click(Source As Button)
      Print "Submitting mail to approving person ..."
      Dim ws As New notesuiworkspace
      Dim uidoc As notesuidocument
      Dim doc As notesdocument
      Dim item As NotesItem
      Dim numvalues As Integer
      Dim session As New notessession
      Dim db As notesdatabase
      Dim maildoc As notesdocument
      Dim Body As NotesRichTextItem
      Dim hard As String
      
      Set db=session.currentdatabase
      Set uidoc=ws.currentdocument
      Set doc=uidoc.document
      tmpamount=Cstr(doc.grandtotal_n(0))
      
      Dim view As notesview
      Set view=db.getview("urviewname")
      Set parentDoc = view.GetParentDocument( doc )
      'SEND MAIL TO DEPT HEAD.
      
      Dim item1 As notesitem
      Set item1 =doc.getfirstitem("approver_x")
'      For y = 0 To Ubound(item1.values)
      Set maildoc = New NotesDocument( db )
      maildoc.Form = "Memo"
      '      If (uidoc.Fieldgettext("adjust_k")="Adjust Leave") Then
      maildoc.Subject ="New Payment Voucher Request"
      Set Body=New NotesRichTextItem(maildoc,"Body")
      message="Please check the items requested to this month for our department for the amount "+tmpamount+" and take necessary action. Thank you."
      '      Else
      '            maildoc.Subject = _
      '            "Leave Application"
      '            Set Body=New NotesRichTextItem(maildoc,"Body")
      '            message="Please review my leave application for "+tmpamount+" days. Thank you."
      '      End If
      
      Call Body.AppendText(message)
      Call Body.AddNewLine(2)
      message1="Click here to open the form=========>>"
      Call Body.AppendText(message1)
      Call Body.AppendDocLink(parentdoc,"Please click this link to open the document")
      Call Body.AddNewLine(2)
      mess="(This is an auto-generated email. You may delete this after review.)"
      Call Body.AppendText(mess)
      For y = 0 To Ubound(item1.values)
            hard=item1.values(y)+"@stoneforest.com.sg"
            Print "Submitted to : "+item1.values(y)
            
            Call maildoc.Send( True, hard)
      Next
      
      
      
End Sub
0

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
madheeswarCommented:
first u need to save the currentdcoument and refresh view and then use this code.
0
ZopiloteAuthor Commented:
Madhesswar,
Many thanks to you (and Arun)

The script worked as:

Sub Click(Source As Button)
      Print "Submitting mail..."
      Dim ws As New notesuiworkspace
      Dim uidoc As notesuidocument
      Dim doc As notesdocument
      Dim parentDoc As NotesDocument
      Dim session As New notessession
      Dim db As notesdatabase
      
      Dim maildoc As notesdocument
      Dim Body As NotesRichTextItem
      
      Dim item1 As notesitem
      Dim item As NotesItem
      Dim Recipient As String
      
      Set db=session.currentdatabase
      Set uidoc=ws.currentdocument
      Set doc=uidoc.document
      Set parentDoc = GetParentDocument( doc)
      
      Set maildoc = New NotesDocument(db)
      Set Body=New NotesRichTextItem(maildoc,"Body")
      
      maildoc.Form = "Memo"
      maildoc.Subject ="New Payment Voucher Request"
      
      Recipient= "TestUser"
      message="Hello World"
      message1="Click here to open the form=========>>"
      mess="(This is an auto-generated email. You may delete this after review.)"
      
      Call Body.AppendText(message)
      Call Body.AddNewLine(2)
      Call Body.AppendText(message1)
      Call Body.AppendDocLink(parentDoc ,"Please click this link to open the document")
      Call Body.AddNewLine(2)
      Call Body.AppendText(mess)
      
      Call maildoc.Send( False, Recipient )
      
End Sub

Function GetParentDocument( doc As NotesDocument )
      Dim db As NotesDatabase
      Dim parentDoc As NotesDocument
      Set db = doc.ParentDatabase
      If doc.IsResponse Then
            Set parentDoc = db.GetDocumentByUNID _
            ( doc.ParentDocumentUNID )
      End If
      Set GetParentDocument = parentDoc
End Function

I thank you again for your prompt answer. I am increasing the points and then accepting your answer.

Merci beaucoup!

Z;D
0
madheeswarCommented:
Ok. Ur welcome
0
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.

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.