?
Solved

Button to Agent

Posted on 2003-10-21
7
Medium Priority
?
250 Views
Last Modified: 2013-12-18
How can this code be changed to work in an agent as opposed to where I currently have it... in a button?  I'd rather have the button trigger the agent.


Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim curdoc As NotesDocument
      Dim db As NotesDatabase
      Dim view As NotesView          
      Dim PartNo As String
      Dim answer As Integer
      Dim codeType As String
      Set uidoc = workspace.CurrentDocument
      If uidoc.IsNewDoc Then
            Set curdoc = uidoc.Document
            Set db = curdoc.ParentDatabase
            Set view = db.GetView("VendorTable")'All Fields Values sorted
            PartNo = uidoc.FieldGetText("ven_num") 'The FieldName you want to check
            Set doc = view.GetDocumentByKey(PartNo)
            If Not (doc Is Nothing) Then
                  Forall i In doc.Items
                        If (i.Text = PartNo) Then codeType = "Vendor Number"
                  End Forall
                  answer = Messagebox( "Duplicate " & codeType & " found. Switch to existing Vendor document?", 1+32, "Duplicate Vendor Document")
                  If (answer = 1) Then
                        curDoc.SaveOptions = "0"
                        Call uidoc.Close          
                        Delete uidoc
                        Call workspace.EditDocument(True, doc)
                  End If
            End If  
      End If      
End Sub
0
Comment
Question by:schmad01
[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
7 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 500 total points
ID: 9594072
If this is an agent that is run in foreground via agent, then you can just copy and paste it in initialize event . And call it from button either using simple action "Run Agent" or ToosRunMacro command

This cannot be a scheduled/background agent.

~Hemanth
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9594152
Put the code in the agent with properties as :

Shared agent

Manually from Agents List

Run Once @Commands May be used.

LotusScript

Paste the code in the initialize event.

Now, create a button and have the

@command([ToolsRunMacro];"AGENT NAME")

to run the agent.  Make sure you use (Agent Name) with in paranthesis since the agent will be hidden in this case.

Good Luck!
Arun.

0
 

Author Comment

by:schmad01
ID: 9594186
Thanks alot.  I was pasting it in Declarations, no wonder I was getting errors.
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 9

Expert Comment

by:Arunkumar
ID: 9594197
:-)
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9594217
You shoudl have been able to paste in (Decalartions), and Notes should have created a new subroutine automatically.  Well, water under the bridge, I guess.
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9594227
well if you dont have sub initialize and end sub copied into your clipboard then you will get these kinds of errors right ?
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9594272
Nope, you will just have an empty initialize, and a sub called click that is never executed
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

741 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