Solved

Getting a value from a form in a LotusScript Agent

Posted on 2004-08-04
8
188 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 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