Main Views

June 28, 2010

Since SLX 6.2, the Account, Contact, and Opportunity entities have been implemented as Main Views.

If you want to create your own custom Main View (e.g., for hospital Cases, or company Projects) entity, these are the steps:

  1. In the Picklist Manager, on the Plugin Families tab, add a “MyEntity” value to the Active Form Types, Active Script Types, Main View Types, Menu Types, Report Families, and Toolbar Types picklists
  2. Create a new table (e.g., MyEntity), not associated with any other tables
  3. Create a new MyEntity Detail Main View, bound to the MyEntity table; set the EntityNamePlural and EntityNameSingular properties; and save it under the MyEntity plugin family
  4. Create an Insert New MyEntity Data Form, bound to the MyEntity table
  5. Create a MyEntity Details form, and assign it to the ViewName property of the DetailsView control, on the MyEntity Main View
  6. Create a new lookup (Manage -> Lookups) against the MyEntity table, to be used as the QuickFindLookup on the MyEntity Main View. (For lookups, the Search field is the field searched on, e.g., the field which the “Starting With” value is applied to; the LookupID is what it returns [e.g., to the LookupID field of a LookupEdit control], as an SLX Standard ID; and the Name field is “the value that would be displayed in a LookupEdit when the lookup returns [like a contact name, address info, etc.”])
  7. Create tabs for the Main View (tabs are just Data Forms, bound to the MyEntity table, with the default panel and buttons removed)
  8. Add those tabs to the DefaultTabs list property of the Main View TabsPane control
  9. On the Standard Menus plugin, add a new item to launch the Insert New MyEntity form
  10. In the Standard Menus plugin, create a new MyEntity NavMenu entry. (The OTB right-click popup items for the Sales Toolbar [!] can be found in the same Standard Menus plugin, below the main menu items; e.g., Contacts NavMenu)
  11. On the Sales Toolbar, add an item to jump to the MyEntity Main View (i.e., an Action value of Function, with an Argument of MyEntity:MyEntity Detail). Set its Popup menu property to the MyEntity NavMenu
  12. On the Standard Toolbar, add a new item (with icon) to Insert New MyEntity, which launches the MyEntity:Insert New MyEntity form
  13. Add an item to the Lookup main menu (in the Standard Menu plugin) to launch your MyEntity lookup via a script, using the LookupItemWithConditionByID function (example)

You can’t change the bound-table for a Data Form after it’s created, so if you want to reproduce the normal Attachments or Contacts tabs for the MyEntity entity, you can’t just save them under the new Family. What you’ll have to do instead is create a new Data Form, bound to the MyEntity table, and then copy-and-paste the code and the controls from the existing OTB tab, onto your new one.

In 7.5, the Activities tab (and also the Summary tab) are still part of the compiled functionality of SLX; so if you want to have an Activities tab for the MyEntity entity, you’ll have to build it from scratch.

Of course, if you’re associating Activities with MyEntity records, you’ll also need to modify the Activity Detail View form, and add a MyEntityID field to the Activity table, data-bound from the Activity Detail View. You can do a similar thing for the MyEntity Notes/History tab, adding the MyEntityID field to the History table.

If your MyEntity Main View is displaying “%n of %n records” at the top, or if the All MyEntities group in the (F8) groups view contains no records, check to make sure that your lookup has been assigned to the QuickFindLookup property of the Main View, that it exists on the database in question (i.e., if you’re in QA or production, it should have been bundled and applied), and doesn’t include fields which don’t exist in the MyEntity table.

Also, for the menu/toolbar additions above, it’s much preferable to do those in new plugins, which simply add/remove options from the OTB Standard Menu, Standard Toolbar, and Sales Toolbar. That way, when it comes time to upgrade to the next version, you don’t have to search through the OTB menus/toolbars to try and figure out what you’ve added or deleted from them.


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._
  • 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
    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)
    They also have similar Tabs collections, and a PopupMenu property which returns a PopupMenuX class object:
  • 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