Tips and Tricks – II

May 5, 2010

More Tips and Tricks….

  • To execute a method of a control on another form:
Set oForm = Application.Forms("Ticket:Support Ticket Widgets")
oForm.DataGrid1.Refresh
  • You can turn off “Open project at startup” via the Tools > Options menu in Architect
  • To delete an old version of a plugin, right-click on it in Plugin Manager, select Properties…, and remove the checkmark from the Read Only checkbox. Click OK. Then press the Delete key. You will be prompted for whether you are sure that you want to delete the plugin. Click Yes
  • If you set the ShowGroupPanel property of a DataGrid to True, it will create a blank (dark gray) area above the grid’s table. You can then drag any column header from the grid into that area, allowing the user to group by that field
  • The SysInternals Suite from Microsoft contains, among many other goodies, a DebugView utility. If you put lines like
Application.Debug.WriteLine Err.Number
Application.Debug.WriteLine "Creating Recordset"
    into your SLX scripting, and then run the dbgView.exe, you can read the WriteLine’s there

  • The SLX Mail Merge engine calls the System:SLX Mail Merge OnCustomFieldName script whenever it encounters a custom field in a (Word template) document. “This allows us to insert whatever data we need to in the document at merge time” (Stephen Redmond)
  • The recommended way of creating new recordsets in SLX is to use this function:
Application.CreateObject("ADODB.Recordset")
  • Using DoEvents in SLX VBScripting works fine, but there’s also Application.DoEvents
  • To programmatically create a new activity, use the Application.Activities class:
Set Act = Application.Activities.Add(atPhoneCall)
Act.AccountID = strAccountID
Act.StartTime = DateAdd("d", 7, Now)
Act.Save
  • The “Insert:ContactAccount” function, for inserting new Accounts/Contacts, calls the System:ChooseContactAccount plugin
  • When closing a form via Application.BasicFunctions.CloseCurrentView blnValue, passing True causes the form to be closed as if the user clicked the Cancel button; passing False closes the form as if the OK button had been pressed (i.e., also running any validation code before it closes)
  • Use Application.BasicFunctions.GetGroupList(Family, Type) to retrieve a list of either all of the groups available to the current user (Type = 0 returns string names, Type = 1 returns the actual plugin IDs). Use GetGroupSQL to retrieve a particular group’s SQL (by its ID). Use GetGroupIDs to get a handle to the comma-separated list of IDs in a group, and then use GetGroupCount and GetGroupValue (0-based) with that handle to iterate through the list, to parse it out into its individual ID values
  • For parsing general CSV strings, use CSVCount and CSVField (to get the value in the 1-based position, from 1 to CSVCount)
  • Use GetLineCount and GetNthLine to parse strings where there is a carriage return and line feed separating the values (e.g., from ParseName)
  • GetOwnerName returns the name for a given SecCodeID value
  • To get an OTB path where you can create your own temporary files, use GetPersonalDataPath (SLX already stores copies of reports that are run, or checked out of Architect, in that folder)
  • To attach a new file to an ACO record, use InsertFileAttachment. If you already know the path to the file you want to attach, use InsertFileAttachmentEx instead
  • To transform a string in ISO format (yyyymmdd hh:mm:ss) into a date variable, use ISOToDate
  • In custom code (as opposed to the OTB SLX functionality) and on DataGrids, deleting an Account doesn’t automatically delete its Contact, Opportunities, Activites, or History records, etc. To cause that cascade-deletion to happen, you’ll need to call CascadeDelete strEntity, strEntityID for the parent entity. That will cascade through all of the Joined tables where CascadeDelete is set to “Delete”