Solved

Getting a value from a form in a LotusScript Agent

Posted on 2004-08-04
8
183 Views
Last Modified: 2013-12-18
Here is my agent

Function SendLinkToApprover(recipient As String)
      Dim rtitem As NotesRichTextItem
      
      mailDoc.SendTo = recipient
      mailDoc.Subject = "A Metrology Specification Requires Your Approval"
      
      Set rtitem = mailDoc.CreateRichTextItem("Body")
      Call rtitem.AppendText("Click on the link below to access the approval document")
      Call rtitem.AddNewLine(2)
      
      linkString =  "https://server.com" & dc.HTTPDbLoc(0) & "/0/" & dc.DocID(0) & "?EditDocument"
      Call rtitem.AppendText(linkstring)
      mailDoc.Send(False)
      
End Function

I have a form named -> VendorApprovalReport
In the form I have a field named ->ApprovalPN

I need to add this value to the subject
mailDoc.Subject = "A Metrology Specification" + ApprovalPN + "Requires Your Approval"


Not sure how to set up the script to pull the value from the form? This may be simple but I need this pretty quick!
0
Comment
Question by:Jaziar
  • 4
  • 2
  • 2
8 Comments
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 150 total points
ID: 11718315
Change fucntion header to:

Function SendLinkToApprover(recipient As String , ApprovalPN as String)

Then change the mailDOc.Subject = line to exatcly your modified one.

Finally, change the call to the function from:
Call SendLinkTApprover ( "recipient name")
To:
Call SendLinkTApprover ( "recipient name", doc.ApprovalPN(0))


Note that the functin is badly coded... it uses an external document called mailDoc (a Global), which means it has side effects.  I would have done this differently.
0
 

Author Comment

by:Jaziar
ID: 11718701
Call SendLinkTApprover ( "recipient name") - Im not finding this call in the script.  SHould add it? And COngrats on being Featured Expert
0
 

Author Comment

by:Jaziar
ID: 11718971
This is the Initialize script in the agent

Sub Initialize
      Call InitializeGlobals()
      
      If dc.SaveOnlyFlag(0) <> "1" Then
            
            If IsRejected(dc) Then
                  Call SendRejectionNoticeToInspector
            Else
                  
                  recipient = WhoAmIMailingTo()
                  
                  If recipient = dc.ApprovalInspectedBy(0) Then
                        SendLinkToInspector(recipient)
                  Elseif recipient <> "" Then
                        SendLinkToApprover(recipient)<- IS THIS THE PLACE TO ADD               SendLinkTApprover ( "recipient name", doc.ApprovalPN(0))

                  End If
                  
            End If
      End If
End Sub

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 11723878
Yuck! I suppose that your function InitializeGlobals creates and initialises several global variables, like doc and dc. I also suppose taht the function WhoAmIMailingTo() uses these globals. The global variable doc is likely to contain the ApprovalPN item.

Why use local var's if there are globals...  Poor coding indeed.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Jaziar
ID: 11725291
I did not code any of this.  The person who wrote the code left the company and I was left trying to figure what he done.  I don't have the time to re-write it, I just need to place ApprovalPN in the subject thread of the emails.  If you need to see more information please let me know

Function WhoAmIMailingTo As String
      Dim item As NotesItem
      WhoAmIMailingTo = ""
      
      'If signed by last approver then mail goes back to the inspector
      If dc.HasItem("ApprovalPEDESignatureMan") Then
            Set item = dc.GetFirstItem("ApprovalPEDESignatureMan")
            If item.text <> "" Then
                  WhoAmIMailingTo = dc.ApprovalInspectedBy(0)
            Else
                  
                  For i = 0 To 5
                        approverList(i) = dc.GetItemValue(approverFieldList(i))(0)
                  Next
                  For i = 5 To 0 Step -1  'send mail to next approver
                        
                        If approverList(i) <> "" Then
                              WhoAmIMailingTo = approverList(i)
                              Exit For
                        End If
                        
                  Next
            End If
            
      Else
            
            For i = 0 To 5
                  approverList(i) = dc.GetItemValue(approverFieldList(i))(0)
            Next
            For i = 5 To 0 Step -1  'send mail to next approver
                  
                  If approverList(i) <> "" Then
                        WhoAmIMailingTo = approverList(i)
                        Exit For
                  End If
                  
            Next
            
      End If
      
      
End Function
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 150 total points
ID: 11725390
We know you took over someone else's code. No insults meant here.

As Qwaletee said, you can pass the ApprovalPN as a parameter to the function, but since everything is globaly, why should you? As I said, supposedly the doc is a global variable, so you can just add
    doc.ApprovalPN(0)
wherever you like. In this case, you have to ask yourself if you can update the function SendLinkToApprover. Does it ALWAYS have to report the ApproverPN, or only in this case? If it's always to be there, just use doc.ApprovalPN(0) in maildoc.Subject, like
     mailDoc.Subject = "A Metrology Specification " & doc.ApprovalPN(0) & " Requires Your Approval"
0
 

Author Comment

by:Jaziar
ID: 11725573
I am going to split the points -  qwaletee for coming up with the first bit of information and sjef bosman for explaining what is going on in the code - thanks to you both
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 11739351
Jaziar,
> Call SendLinkTApprover ( "recipient name") - Im not finding this call in the script.  SHould add it?
> And COngrats on being Featured Expert
I didn't even realize I was featured.  You'd think they woudl ask first!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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 article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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