API Sample Code
The following are excerpts of SmartSimple Desktop API code written in Microsoft Visual Basic:
Dim ss_param As New SmartComClient.Parameters Call ss_param.addField("opportunityid", "0") Call ss_param.addField("companyid", "404091") Call ss_param.addField("branchid", "404091") ' Call ss_param.addField("opportunitytype", "11642") Call ss_param.addField("name", "test01err") Call ss_param.addField("stageid", "9955") Call ss_param.addField("cf_1333618", "name1") Call ss_param.addField("cf_1333619", "name2") Call ss_param.addField("cf_1590372", "Txt_ACMAddress1.Text") Call ss_param.addField("cf_1590373", "Txt_ACMAddress2.Text") Call ss_param.addField("cf_1590374", "Txt_ACMProvince.Text") Call ss_param.addField("cf_1590375", "Txt_ACMPostalCode.Text") Call ss_param.addField("cf_1590376", "DDL_CITitle.SelectedValue") Dim rtn As Long rtn = tk.updateTable(sess, "levelone", 123123, ss_param) '123123 is the applicationid If rtn = -1 Then MsgBox ("Record Not Updated: " & ss_api.getLastErr) Else
Option Explicit Dim SmartSimple As New SmartComClient.Toolkit Dim Session As SmartComClient.Session Dim Session2 As SmartComClient.Session Dim Userid As Long Private Sub AccessCompanytable_Click() Dim CompanyFields As FieldInfos Dim Fields() As FieldInfo Set CompanyFields = SmartSimple.getFieldsInfo(Session, "companies", 0) Fields = CompanyFields.getFieldInfos MsgBox "There are " & UBound(Fields) + 1 & " associated with this table" End Sub Private Sub AccessContactsTable_Click() Dim ContactFields As FieldInfos Dim Fields() As FieldInfo Set ContactFields = SmartSimple.getFieldsInfo(Session, "contacts", 0) Fields = ContactFields.getFieldInfos MsgBox "There are " & UBound(Fields) + 1 & " associated with this table" End Sub Private Sub AccessUTAlevel1Data_Click() Dim SupportRecords As ADODB.recordset 'check if user login already If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If Set SupportRecords = SmartSimple.GetRecordSet(Session, "levelone", "100073", "name,description", "") MsgBox SupportRecords.RecordCount & " Support Tickets in Recordset" SupportRecords.MoveLast SupportRecords.MovePrevious MsgBox SupportRecords.Fields(0).Value & ": " & SupportRecords("name") & " is the last name in the list" SupportRecords.MoveFirst MsgBox SupportRecords.Fields(0).Value & ": " & SupportRecords("Name") & " is the first name in the list" End Sub Private Sub AddNewContactRecord_Click() Dim para As New SmartComClient.Parameters 'check if user login already If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If para.addField "userid", 0 'If value is 0, anew record will be added para.addField "firstname", "Walter" para.addField "lastname", "Zimmerman" para.addField "phone", "416.555.1212" MsgBox SmartSimple.updateTable(Session, "contacts", para) End Sub Private Sub AddNewlevel1_Click() Dim readOnlyRs As ADODB.recordset Dim writeableRs As ADODB.recordset Dim rtn As Long Set Session = SmartSimple.LoginUser("alias", "SmartSimple.xxx", "userID/e-mail address", "password") Set readOnlyRs = SmartSimple.GetRecordSet(Session, "levelone", "100073", "name,description", "") Set writeableRs = SmartSimple.CloneUpdateRecordset(readOnlyRs) writeableRs.AddNew writeableRs("name").Value = "Test level 1" writeableRs("description").Value = "Test Level 1 Description" writeableRs("opportunityid").Value = 0 writeableRs.Update rtn = SmartSimple.updateTableByRecordSet(Session, "leveline", writeableRs, False) 'False will loop thru whole recordset, tru will process current record only. End Sub Private Sub CheckSettings_Click() Dim LastLogin As String LastLogin = "Alias:" & SmartSimple.getLastLoginToken(Alias) & _ " URL:" & SmartSimple.getLastLoginToken(URL) & _ " User Name:" & SmartSimple.getLastLoginToken(UserName) MsgBox (LastLogin) End Sub Private Sub CreateFieldsInTable_Click() Dim CompanyFields As FieldInfos Dim Fields() As FieldInfo Dim FieldName As String Dim I As Integer 'MS-Word Objects Dim FieldTable As Table Dim TableColumn As Column Dim NoRows As Integer Dim Row As Integer 'Extract fields Set CompanyFields = SmartSimple.getFieldsInfo(Session, "contacts", 0) Fields = CompanyFields.getFieldInfos 'Create MS-Word table based on number of fields NoRows = UBound(Fields) Set FieldTable = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=NoRows, NumColumns:=5) For I = 0 To UBound(Fields) - 1 FieldTable.Cell(I, 1).Select Selection.TypeText I FieldTable.Cell(I, 2).Select Selection.TypeText Fields(I).Name FieldTable.Cell(I, 3).Select Selection.TypeText Fields(I).FieldType FieldTable.Cell(I, 4).Select Selection.TypeText Fields(I).ID FieldTable.Cell(I, 5).Select Selection.TypeText Fields(I).FieldOptions Next I End Sub Private Sub DisplayError_Click() If SmartSimple.getLastErr <> "" Then MsgBox SmartSimple.getLastErr Else MsgBox "No Error Found" End If End Sub Private Sub DisplayLevel2_Click() Dim SupportRecords As ADODB.recordset Dim SupportActivities As ADODB.recordset Dim TicketName As String Dim TicketID As Long Set Session = SmartSimple.LoginUser("alias", "SmartSimple.xxx", "userID/e-mail address", "password") Set SupportRecords = SmartSimple.GetRecordSet(Session, "levelone", "100073", "name,description", "") TicketID = SupportRecords.Fields(0).Value Set SupportActivities = SmartSimple.GetRecordSet(Session, "leveltwo", "100073", "subject,description", "objectid = " & TicketID) MsgBox "Number of Actions on the First Ticket: " & SupportActivities.RecordCount End Sub Private Sub DisplayUserDetails_Click() Dim para As SmartComClient.Parameters If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If Set para = SmartSimple.getData(Session, "contacts", 0, "userid,firstname,lastname,phone,rolelist", " email='" & "sampleuser@address.com" & "'") If para Is Nothing Then MsgBox SmartSimple.getLastErr ' Error return null object, normally invalid password or wrong url Else ' Storing primary key to a global variable used later for update Userid = Val(para.getValue("userid")) MsgBox "First Name: " & para.getValue("firstname") & vbCrLf _ & "Last Name: " & para.getValue("lastname") & vbCrLf _ & "Phone: " & para.getValue("phone") End If End Sub Private Sub DownLoadRecords_Click() Dim Records As String 'Records = SmartSimple.getDataFile(Session, "contacts", "firstname,lastname,title,phone", "isexternal=0") End Sub Private Sub GetCollection_Click() 'check if user login already If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If End Sub Private Sub GetNotes_Click() Dim Roles As SmartComClient.Roles Dim assoicate As New SmartComClient.associate If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If End Sub Private Sub GetRecordSet_Click() Dim ContactRecords As ADODB.recordset 'check if user login already If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If Set ContactRecords = SmartSimple.GetRecordSet(Session, "contacts", 0, "firstname,lastname,email", "email like '" & "*sampleaddress.com" & "'") MsgBox ContactRecords.RecordCount & " Records in Recordset" ContactRecords.MoveLast MsgBox ContactRecords("lastname") & " is the last name in the list" ContactRecords.MoveFirst MsgBox ContactRecords("lastname") & " is the first name in the list" End Sub Private Sub Logout_Click() If Session Is Nothing Then MsgBox "You are not logged into SmartSimple" Else SmartSimple.LogoutOut (Session) MsgBox "Logged out" End If End Sub Private Sub NoPrompt_Click() Dim Alias As String, _ ServerURL As String, _ User As String, _ Password As String 'All values set in code Alias = "alias" ServerURL = "alias.smartsimple.xxx" User = "userID/e-mail address" Password = "password" Set Session = SmartSimple.LoginUser(Alias, ServerURL, User, Password) End Sub Private Sub PasswordOnly_Click() Dim Password As String Password = InputBox("Enter Your Password") Set Session = SmartSimple.LoginUserWithLastSetting(Password) End Sub Private Sub Prompt_Click() Dim Parameters As SmartComClient.Parameters If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If End Sub Private Sub SessionProperties_Click() If Session Is Nothing Then MsgBox "Session not Valid - Please Log in" Else MsgBox "Session Alias: " & Session.Alias & vbCrLf _ & "Server URL: " & Session.ServerURL & vbCrLf _ & "User Full Name: " & Session.ss_FullName & vbCrLf _ & "User Name: " & Session.User & vbCrLf _ & "UserID: " & Session.ss_UserID & vbCrLf _ & "Password: " & Session.Password & vbCrLf _ & "Organisation: " & Session.ss_CompanyName & vbCrLf _ & "OrganisationID: " & Session.ss_Companyid & vbCrLf _ & "Root Organisation: " & Session.ss_RootCompanyid, vbOKOnly, "Session Settings" End If End Sub Private Sub SSLEnable_Click() SmartSimple.setSSL (True) End Sub Private Sub TwoSessions_Click() Set Session = SmartSimple.LoginUser("alias1", "SmartSimple.xxx", "e-mail address1", "password1") Set Session2 = SmartSimple.LoginUser("alias2", "SmartSimple.xxx", "e-mail address2", "password2") End Sub Private Sub UpdateUserDetails_Click() Dim para As New SmartComClient.Parameters If Session Is Nothing Then Set Session = SmartSimple.PromptLogin() End If If Session Is Nothing Then MsgBox SmartSimple.getLastErr Exit Sub End If 'Update Table para.addField "userid", Userid & "" para.addField "firstname", "New First Name" para.addField "lastname", "New Last Name" para.addField "phone", "555-1212" If SmartSimple.updateTable(Session, "contacts", para) = -1 Then MsgBox "Record Not Updated" Else MsgBox "Record Updated" End If End Sub