?
Solved

Getting a value from a form in a LotusScript Agent

Posted on 2004-08-04
8
Medium Priority
?
189 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 600 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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