[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Button to Agent

Posted on 2003-10-21
7
Medium Priority
?
251 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
Technology Partners: 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 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

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

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…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
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 a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 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