Tips and Tricks – IV

May 20, 2010

Tips and Tricks IV: The Voyage Home.

  • SalesLogix performance will suffer with cursors being left open. If you are coding in SalesLogix it is very important that you close your Recordsets, setting your Recordsets to Nothing is NOT enough, you should always have code like this:
If oRS.State = 1 Then
    oRS.Close
End If
Set oRS = Nothing
' Need to restrict the Lookup to records where
' Account.Type='Customer' and Account.Location='US'):
LookUpName = "Account:Account"
RestrictAlways = True
Lookup.LookupRestrictField = "TYPE'"
Lookup.LookupRestrictOp = "='Customer' and LOCATION="
Lookup.LookupRestrictValue = "US"
  • Create a “.txt” file. Rename the file to “.udl”. When you double-click on the file it will display the standard connection designer!

And lots of good stuff from Ryan Farley’s site:


Tips and Tricks – III

May 7, 2010

Yet more Tips and Tricks….

  • To display the Owner lookup dialog, with a default item selected, use:
strSecCodeID = Application.BasicFunctions._
    LookupOwner(strDefaultSecCodeID)
  • To display the Select User dialog, use:
objUser = Application.BasicFunctions.LookupUser
strUserID = objUser.ID
strDisplayName = objUser.DisplayName

To have a default User selected in the lookup, use LookupUserEx instead

  • To have the user select an application to open an attachment with, use OpenAttachmentWith
  • SLX has a number of registry-related functions: RegSetValue, RegGetValue, RegDeleteValue all relate to HKEY_CURRENT_USER\Software\SalesLogix\UserValues and, unlike the WScript.Shell class, can only read/write String data types
  • To edit Activities, use Application.BasicFunctions.ShowActivity or ShowActivityNotePad[Ex]; use ShowHistory to edit History records. Also Application.Activities.GetActivityList and GetActivityByID
  • Processes: Use StartContactProcess to start a Contact Process against the specified ContactID, OpportunityID, or GroupID
  • To open a URL in the default browser, use WebOpen
  • You can store any data type in a SalesLogix global variable … include objects like recordsets
  • To access picklists and their items without using SQL, use (via Stephen Redmond’s DevLogix):
Set pl = Application.PickLists(strMyPickListName)
For i = 0 to pl.Count - 1
    strText(i) = pl.Item(i).Text
Next
    Also note the ItemByText and ItemByShortText methods.

  • Main Views have GroupsPane collections:
For i = 0 To MyMainView.GroupsPane.Selection.Count - 1
    strGroupID(i) = MyMainView.GroupsPane.Selection.item(i)
Next
    They also have similar Tabs collections, and a PopupMenu property which returns a PopupMenuX class object:
mv.PopupMenu.Items(0).Click
  • To set the current group: Application.BasicFunctions.SetCurrentClientGroup strGroupName
  • Application.Translator.StrToInt converts strings to integers, even if the strings are using comma characters as the decimal-separator rather than the thousands-separator (the function always uses the thousands separator specified in the Regional settings for the current Windows user.)
  • Form.Script.C_CheckDates would execute subroutine ‘C_CheckDates’ defined under the form Script tab
  • Microsoft Script Debugger is here
  • You can use the fx_rowaccess() “stored procedure” in a normal SQL statement:
SELECT account, type, division, employees, credithold,
creditamount, fx_rowaccess() from ACCOUNT