Solved

Very Urgent-How can I let user set existing Calendar entries to be sent as SMS using lotusscript only

Posted on 2003-10-25
16
331 Views
Last Modified: 2013-12-18
Hi,
  I require an immediate solution... I am not sure how to implement this functionality. I will explain the scenario. I have to present the user the list of existing calendar entries from which he can choose one or more calendar entries to be sent as SMS. For the entries which he chooses. I have to send an SMS half an hour before that scheduled time in the entry.

Let me tell you what I have tried. I have created a view which inherits the calendar outline... I have added two more columns in which one column- I thought I will set the flag value to be sent as SMS and the other column to show a mobile icon based on the SMS flag value set. Then I thought of creating an agent which is scheduled for every 5 minutes and any calendar entries which fall in the 5 minutes provided that entry is set to be sent as SMS I want to call an external DLL function which sends the SMS.


The following is the code which I am using the to show the user the various entries from which the user selects

Sub Click(Source As Button)
      Dim session As New notessession
      Dim database As NotesDatabase
      Dim uiws As New NotesUIWorkspace
      Dim collection As NotesDocumentCollection
      Dim noteCursorDoc As NotesDocument
      Dim itemflag As NotesItem
      Dim vc As NotesViewEntryCollection
      Dim view As NotesView
      Dim entry As NotesViewEntry
      Dim text As String
      
      Set database = Session.CurrentDatabase
      Set view = database.GetView("($SMSRemainders)")
      Set noteCursorDoc = database.CreateDocument
      Set vc = view.AllEntries
      Set entry = vc.GetFirstEntry
      Set database = session.CurrentDatabase
      Set collection = uiws.Picklistcollection(PICKLIST_CUSTOM, True, database.server, database.filepath, "($SMSRemainders)", "SMS Reminders", " ")
      If collection.count > 0 Then
            Set noteCursorDoc = collection.GetFirstDocument
            Set item = noteCursorDoc.GetFirstItem("Description")
            For i = 1 To collection.Count
                  Msgbox "here"
                  Set itemFlag = New NotesItem(noteCursorDoc, "txtSmsFlag", "")
                  Call noteCursorDoc.ReplaceItemValue("txtSmsFlag","1")
                  Msgbox noteCursorDoc.GetItemValue("txtSmsFlag")(0)
                  Set noteCursorDoc = collection.GetNextDocument(noteCursorDoc)
            Next
      End If            
End Sub

Issuses where  I am stuck:
#1: I am not able to set a flag value for any of the calendar entries which he has selected.
Due to this I am not able to distinguish between the calendar entries which are set for SMS and the existing calendar entries. If someone would give the best optimized solution or some workaround I will the happiest one... This is my module to be completed... I cannot let my self down. Please help.

Please this is very urgent
Thanks in advance...
lara
0
Comment
Question by:lotusnotesnewbie
  • 9
  • 3
  • 3
  • +1
16 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Where is
     Call noteCursorDoc.Save(True,False)
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
I have included that line too.... by mistake just got left out while copy pasting the code. I will also tell you what happended when I did that... I assigned that field(txtSMSflag) to the column. but only the first document reflected the value... the rest of the entries selected showed nothing in the column. :-((( I wasted almost 4 hours trying fix that things... no luck... I tried to get that Items value using message box it returns correct... still    it didnt reflect in all the documents...
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
I have also tried this workaround...
I tried to create a new document and create two fields one which stores the unique id of the calendar entries selected and the other is an flag value and I thougnt I will put it in another view and using my agent compare the documents in both the views... which has similar unique id's and then send the SMS. :-((( things are just pulling me down... and I have just one day more to finish this module.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
I removed the superfluous statements, see the code below.

Sub Click(Source As Button)
     Dim session As New notessession
     Dim database As NotesDatabase
     Dim uiws As New NotesUIWorkspace
     Dim collection As NotesDocumentCollection
     Dim noteCursorDoc As NotesDocument
     
     Set database = Session.CurrentDatabase
     Set view = database.GetView("($SMSRemainders)")
     Set collection = uiws.Picklistcollection(PICKLIST_CUSTOM, True, database.server, database.filepath, "($SMSRemainders)", "SMS Reminders", " ")
     If collection.count > 0 Then
          Set noteCursorDoc = collection.GetFirstDocument
          Do Until noteCursorDoc Is Nothing
               Call noteCursorDoc.ReplaceItemValue("txtSmsFlag","1")
               Call noteCursorDoc.Save(True, False)
               Msgbox noteCursorDoc.GetItemValue("txtSmsFlag")(0)
               Set noteCursorDoc = collection.GetNextDocument(noteCursorDoc)
          Loop
     End If          
End Sub

When debugging, you'd better check the document properties on the Fields tab for the content of every field. Calendar views are funny things.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Lara, There is no need to create new item and do a replace item.

Your code where you set the code should be changed to this.

               Msgbox "here"
               notesCursorDoc.txtSmsFlag = "1"
               Call noteCursorDoc.Save(True, False)
               Set noteCursorDoc = collection.GetNextDocument(noteCursorDoc)

~Hemanth
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Eh, what's the difference (except for the additional faulty "s" in your second line)?
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Hay thanks sjef_bosman... it just like that worked like a miracle... You have pulled me half way out the pit... How about the agent... which is the optimized way to set the agent so that it will send the SMS before 30 minutes of each calendar entry set for SMS...
Save me completely na... so that I get over this...
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 125 total points
Comment Utility
You know what?  Notes has almost all of that functionality built in. That's how the "Notify Me" function works in the calendar.  ou can either try to take exact advantage of the built in features, or try to use as much of teh existing code as possible.

Using as-is:

The Notify Me function allows the user to select when to notify for that entry, and you can notify via e-Mail. Unfortunately, it requires the Notes client to be running to do this.  Also, if the user does not clear the first pop-up, the second pop-up may not send the message immeidately.  you can use NotesMinder, though, which comes with Notes, and does not have these limitations. (Although yo must keep at least Notes Minder running at all times).

Using with slight modification:

The Notes client puts eveything that has a notification into a hidden folder named ($Alarms).  The folder's first column is the exact alarm time (i.e., if you specify 10 mnutes before an event set for 3:00 PM, then it will have 2:50 PM in the first column).  The first column is sorted, with oldest at the top.

So, all you really need to do is process the alarms view slightly before the client would!

And you don't need a DLL; all SMS phones have an e-Mail address.

Here's some sample code; set this agent to run every five minutes

Dim s as new NotesSession
Dim db as notesDatabase
Set db = s.currentDatabase
Dim view as notesView
Set view = db.getView("($Alarms)")
Dim doc as notesDocument
Set doc = view.getFirstDocument
Dim cutoffObj as new notesDateTime(now)
cutoffObj.adjustMinutes(-10)
Dim cutoff
cutoff = cutoffObj.lsLocalTime
const flagField = "Custom_SentSMS"
Dim sms as new notesDocument ( db )
sms.Form = "Memo"
Dim defaultSendTo as string
defaultSendTo = "user's SMS e-Mail address - you figure out this one"
do until doc is nothing
  if doc.columnValues(0) > cutoff then
     set doc = nothing 'do not process the rest, we aren't there yet
  elseif not doc.hasItem(flagField) then
     sms.Subject = doc.columnValues(3)
     sms.SendTo = doc.columnValues(5)
     if trim(sms.sendTo(0)) = "" then sms.sendTo = defaultSendTo
     sms.Send false
     doc.replaceItemValue flagField , "1"
     doc.save false,false
  end if
loop

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Hi qwaletee,
  THanks in advance for your comment, I am still working on it. Hoping I will come up with big Hurray...
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Some one pleaseeeeeeee help...
this is the code I am using to schedule the agent every 5 minutes and send mail. Each time when I run the agent the time difference is not decreasing but it keeps on increasing. So what happens is it never comes to the else part where I am trying send a message

Sub Initialize
      Dim s As New NotesSession
      Dim Current1 As New NotesDateTime(Now)
      Dim sms As notesDocument                              
      Set db = s.currentDatabase
      Set notificationView = db.getView("($Alarms)")
      Set notificationDoc = notificationView.GetFirstDocument
      If Not notificationDoc Is Nothing Then
            txtDocFlag = notificationDoc.GetItemValue("txtSMSFlag")(0)
            txtSmsStartDateTime = notificationDoc.GetItemValue("StartDateTime")(0)
            txtSmsLocation = notificationDoc.GetItemValue("Location")(0)
            txtSmsSubject = notificationDoc.GetItemValue("Subject")(0)
            txtSmsBody = notificationDoc.GetItemValue("Body")(0)
            Msgbox "AlarmTime" & notificationDoc.ColumnValues(0)
            Msgbox "CurrentTime" & Current1.lslocaltime
            Msgbox "NowTime" & Now
            Dim AlarmTime As New NotesDateTime(notificationDoc.ColumnValues(0))
            Do Until notificationDoc Is Nothing
                  If Current1.TimeDifference(AlarmTime) >= 0 Then
                        Msgbox "ifalsams" & Current1.TimeDifference(AlarmTime)
                        Set notificationDoc = Nothing
'do not process the rest, we aren't there yet
                  Else
                        Msgbox  "else aaskdj" & Current1.TimeDifference(AlarmTime)
                        If notificationDoc.GetItemValue("txtSmsFlag")(0) = "1" Then
                              smsRemainderSubject = Cstr(txtSmsStartDateTime) & " " & Cstr(txtSmsLocation) & " " & Cstr(txtSmsSubject) & " " & Cstr(txtSmsBody)
                              Set sms = db.CreateDocument
                              sms.Form = "Memo"
                              sms.Subject = Cstr(txtSmsStartDateTime) & " " & Cstr(txtSmsLocation) & " " & Cstr(txtSmsSubject) & " " & Cstr(txtSmsBody)
                              sms.SendTo = "elavarasi_j@hotmail.com"
                              sms.Send False
                              notificationDoc.replaceItemValue txtSmsFlag , "0"
                              notificationDoc.save False,False
%END REM
                              Msgbox "Mail Sent"
                        Else
                              Msgbox "Remainder Flag not set"
                        End If
                  End If
                  If notificationDoc Is Nothing Then
                        Exit Do
                  Else
                        Set notificationDoc = notificationView.GetNextDocument(notificationDoc)
                  End If
            Loop
      End If
End Sub

I utterly dont know where I am going wrong or what I have to do
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Hay thanks now it works. Now I am working on running it has a scheduled agent which runs locally every 5 minutes. I have a problem here because I am reading some values from Registry. If I try to run this agent on server. I am getting "System cannot find the file specified." Is it that the Agent looks up for the registry values in the server???
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
I think this is the most pathetic time I could ever face in my life.... Now I am not able to reset the flag value after sending the message
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Hellooooo why dont some one help
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
We need you to debug the agent to fnd which line causes the problem.  Run it manually instead of in server background mode.

Now, f the problem is with agent rights, you won't get the message.  In that case, just ask teh admin to allow you to run restricted and unrestricted agents using your user ID (or the ID that signs agents).

I did not understand your second question about resetting flag.  What exactly is going wrong?  What is your current code?  Perhaps your code is being aborted before reaching the notificationDoc.save?
0
 
LVL 4

Author Comment

by:lotusnotesnewbie
Comment Utility
Thank you qwaletee for your continuous support my agent is up and running absolutely without any hassles now.
That was one best solution you gave to pull me out from that mind boggling module.
THANK YOU
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
ur welcome
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
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 video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

8 Experts available now in Live!

Get 1:1 Help Now