Solved

Button to Agent

Posted on 2003-10-21
7
246 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
7 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 125 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile Iron iphone stop receiving new mails 6 1,224
SQL Server linked server to Lotus notes 3 456
Switching from Lotus Notes to Outlook 4 46
See used databases in Domino 8 100
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.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now