Add Appointment without dialog |
Here we log in to the database directly, so the SOCRM application does not need to be running for this to work.
If the login fails, then isOk will be false and an error message is displayed.
We use the IFind object to find the id for the contact named "SuperOffice ASA".
We create an appointment and then call the SetDefaults method to make sure it has some sensible values in it before we start tweaking its settings.
The Contact and Task type of the new appointment are set, as is the text of the appointment. Note that the Contact and Task properties take objects instead of ids.
Finally we save the appointment to the database. You should be able to find the appointment in the diary or under the SuperOffice company.
set soDb = CreateObject("SuperOfficeDB.Database") isOk = soDb.Login("user", "pass") if isOk Then enTableTask = 67 ' constant that VBScript doesn't know about contactId = soDB.Find.FirstMatch("contact", "contact\_id", "name", "SuperOffice ASA") set theContact = soDb.GetContact( contactId ) set newAppoint = soDb.CreateAppointment newAppoint.SetDefaults newAppoint.Contact = theContact newAppoint.Template = soDb.GetListItemByName( enTableTask, "Lunch" ) newAppoint.Description = "This is a meeting generated by the Client SDK" newAppoint.Save MsgBox "Appointment created" else MsgBox "Login failed" end if
Up: Getting Started Prev: Typical Usage Next: Create a contact Edit