Solved

Getting a value from a form in a LotusScript Agent

Posted on 2004-08-04
8
187 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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