REM Connection info to login to the Jabber server; REM In a real system, we would ; REM a) not store these in the code and ; REM b) not connect to the server on receipt of every message; Local string &user = "your.user.name.goes.here"; Local string &password = "and.you.know.what.goes.here"; REM The Jabber server host and server name. Here we are using GoogleTalk, ; REM but the Oracle Collaboration Suite IM stuff is also based on the Jabber/XMPP standard; REM as are many other open source and commercial IM servers; Local string &host = "talk.google.com"; Local string &serverName = "gmail.com"; REM We use a unique resource name since we're logging in multiple times with our Jabber account; Local string &resource = "ReportNotifier"; REM ************* No need to change anything below here ***************************; Local Rowset &rsReportMessage = GetMessage().GetRowset(); REM Dig out the report URL and who has access to it; Local Row &rowReport = &rsReportMessage.GetRow(1); Local Record &recReport = &rowReport.GetRecord(Record.PSRF_RCREAT_WRK); Local string &sReportURL = &recReport.GetField(Field.PSRF_REPORT_URL).Value; Local Rowset &rsReportSecurity = &rowReport.GetRowset(Scroll.PSRF_RSCRTY_TBL); REM This code uses the convention of the "Other" type in the user's email list for storing ; REM their Instant Messaging ID. That was purely to keep the demo simple though ; Local array of string &arrUsers = CreateArrayRept("", 0); For &nUserCtr = 1 To &rsReportSecurity.ActiveRowCount; Local Record &recRepSec = &rsReportSecurity.GetRow(&nUserCtr).GetRecord(Record.PSRF_RSCRTY_TBL); Local string &sUserId = &recRepSec.GetField(Field.USERID).Value; Local string &sXMPPId, &sUserName; If SQLExec("SELECT A.EMAILID, B.OPRDEFNDESC FROM PSUSEREMAIL A, PSOPRDEFN B WHERE B.OPRID = A.OPRID AND A.EMAILTYPE = 'OTH' AND A.OPRID = :1", &sUserId, &sXMPPId, &sUserName) Then &arrUsers.Push(&sXMPPId, &sUserName); End-If; End-For; REM Only send messages if we found some XMPP ids for the users receiving this report; If &arrUsers.Len > 0 Then Local boolean &useSSL = False; Local integer &port = 5222; If &useSSL Then &amp;port = 5223; End-If; Local JavaObject &connection; try Local string &connClassName = "org.jivesoftware.smack.XMPPConnection"; If &useSSL Then &connClassName = "org.jivesoftware.smack.SSLXMPPConnection"; End-If; &connection = CreateJavaObject(&connClassName, &host, &port, &serverName); &connection.login(&user, &password, &resource); Local JavaObject &roster = &connection.getRoster(); REM We have to wait for the presence packets to show up - definitely not production code here! ; GetJavaClass("java.lang.Thread").sleep(3 * 1000); For &nCtr = 1 To &arrUsers.Len Step 2 Local string &sTalkTo = &arrUsers [&nCtr]; Local JavaObject &presence = &roster.getPresence(&sTalkTo); REM Is this person online? ; If &presence <> Null Then Local string &sCR = Char(13) | Char(10); Local JavaObject &chat = &connection.createChat(&sTalkTo); Local string &sMessage = "Hello " | &arrUsers [&nCtr + 1] | ". Your report is ready. " | &sCR; &sMessage = &sMessage | "Here is the link to the report. " | &sCR; &sMessage = &sMessage | &sReportURL | &sCR; &sMessage = &sMessage | "Goodbye. " | &sCR | &sCR; &chat.sendMessage(&sMessage); End-If; End-For; catch Exception &e Warning ("Caught exception: " | &e.ToString()); end-try; If &connection <> Null Then &connection.close(); End-If; End-If;