Click or drag to resize

Common Tasks

Getting the name and id of the current company

This uses the application object, which is tied to the running SOCRM.exe program.

Creating the application object will start SOCRM and start the login process if it is not already running, and prompt the user for a userid and password like normal login.

VB
set soApp = CreateObject("SuperOffice.Application")
currentName = soApp.CurrentContact.Name
currentId = soApp.CurrentContact.Identity
MsgBox currentId & "=" & currentName
Getting the name of a specific company from the SuperOffice database

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 get the record by using the record id. If we don't know the id, but know the name, then we can use the IFind object to find the id for a given name using FirstMatch for example.

VB
set soDb = CreateObject("SuperOfficeDB.Database")
isOk = soDb.Login("user", "pass")
if isOk Then
   contactId = soDB.Find.FirstMatch("contact", "contact_id", "name", "SuperOffice ASA")
   set theContact = soDb.GetContact( contactId )
   id = theContact.Identity
   name = theContact.Name
   MsgBox currentId & "=" & currentName
else
   MsgBox "Login failed"
end if
Adding an appointment to SuperOffice without displaying the appointment 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.

VB
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
Getting the current information from the running application

There are several different Current objects, and you may access  the current object even when the object is not visible. The objects correspond to major parts of the user interface.

Current Contact is the current Contact object that you see in in the company card in  the application. When the Company card changes, it means that the Current Contact has changed.

It has all the properties of a contact (name, department, phones, interests), and any changes you make to CurrentContact are immediately visible.

VB
Set app = CreateObject("SuperOffice.Application")
App.CurrentContact.ChangeIdentity(15)
App.CurrentContact.Name = "Change the name"

Note that changing the current identity or modifying the current object will NOT switch the user interface to edit mode. You need to switch on the EDIT mode explicitly using the EditMode object.

Up: Getting Started   Prev: Simplified Bookings And Invitations   Next: Role-Based Security          Edit