10.07.2015 Views

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example 6-6 Click button eventSub Click(Source As Button)Dim session As New NotesSessionDim db As NotesDatabaseDim agent As NotesAgentDim ws As New NotesUIWorkspaceDim uidoc As NotesUIDocumentDim paramid As StringSet uidoc = ws.CurrentDocumentSet doc = uidoc.documentCall doc.save(True, False)Call uidoc.saveCall uidoc.closeparamid = doc.NoteidSet db = session.CurrentDatabaseSet agent = db.GetAgent("AnnouncementSender")Call agent.run(paramid)End SubWhen the button is clicked, the document is saved and theAnnouncementSender agent is called. The agent is passed the Note ID of thedocument as a parameter to the run() method.If we add the code shown in Example 6-7 to our AnnouncementSender agent, itcan look up the workflow document and extract the user name and message textfrom it. It can then send the announcement containing the specified text to theend user.Example 6-7 Modified NotesMain() method to include lookup codepublic void NotesMain(){try{Session session = getSession();AgentContext agentContext = session.getAgentContext();Database db = agentContext.getCurrentDatabase();Agent ag1 = agentContext.getCurrentAgent();String paramid = ag1.getParameterDocID();Document doc = db.getDocumentByID(paramid);String userName = doc.getItemValueString("username");String announcementText = doc.getItemValueString("announcement");146 <strong>Lotus</strong> <strong>Instant</strong> <strong>Messaging</strong>/<strong>Web</strong> <strong>Conferencing</strong> (Sametime): Building Sametime-Enabled Applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!