I’m working on a web-application where people can select a day when they would like to follow a course.
They can select between pre-defined days.
The problem is that only 10 people can subscribe for each day.
So I would like to work with a counter.
When 10 people are subscribed for a day, that day can’t be selectyed anymore for other people who have to subscribe.
I’ve 2 forms ( a subscription form and a form where I can determine the dates)
On the subscription-form i’ve 2 fields, an author-field and radio-buttonfield where people can select a date. This field uses an @formula to get data from a view.
On the other form i’ve 2 fields.
A field where I can fill in a date and a field where the maximum nrs of subscribers can be filled in.
Is there anyone who can tell me how I can automate this?
You might want to do something along the lines of:
Each time a user is added to a particular day, update the counter on that day document. Use a view that selects those documents but only if the counter in the day document is < 10. Use that view to provide the values in your lookup for available dates.
I already have an agent that runs every time on a save and close of a subscription;
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView("LuEducationdays")
Set doc = view.GetFirstDocument
Do While Not doc Is Nothing
Call doc.Save(True, True, True)
Set doc = view.GetNextDocument(doc)
Loop
End Sub
the meaning of this agent is to open and save the 10 documents where the educationday’s are defined.
When each document is saved the next formula is executed in the querySave;
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim AantalCursisten As String
Dim Entrie As String
Entrie = source.FieldGetText("frmEducationdaysLN7")
Set db = session.CurrentDatabase
Set view = db.GetView("EducationLN7")
Set vc = view.GetAllEntriesByKey(Entrie)
NrParticipants = vc.Count
Call source.FieldSetText("frmEducDayParticipants",NrParticipants)
Call source.Close
End Sub
But it’s not working.
When i open the documents and save them, it works. When i run the agent from a view it’s not working.
The QuerySave will only execute when you have the document you are saving opened in the UI. Since you are not opening the document in the UI, all that is happening is that you are saving the document but without making any changes to it. In this case, you will need to determine what changes you need to write to the document or alternatively (if the changes are too complex to re-code in LotusScript), issue a ComputeWithForm before saving the document