Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting a value from a form in a LotusScript Agent

Posted on 2004-08-04
8
Medium Priority
?
190 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
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!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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