The following is a brief overview of the SalesLogix Lookup control and how to use it in the SalesLogix web client.
Determining the Lookup type
The SalesLogix SLXLookup web control is built upon the standard ASP.Net Lookup control. It offers the ability to bind the lookup to a SalesLogix entity to look up records within that entity this is done using the “Lookup Entity Name”. So if you want the Lookup to lookup accounts you set the “Lookup Entity Name” to the Account entity. Setting the Lookup Entity Name should be the first thing that is done when defining your lookup. if you fail to do this other properties will not correctly work until this is set.
Defining the Lookup Properties
Once you have the Lookup Type defined, the next step is to define what columns are visible in your lookup. This is handled via the Lookup Properties Collection. This collection allows you specify the columns and wether they are used in the filter and which value is used to display when the lookup is used:
- ExcludeFromFilter – Determines if the specified column is one of the available searchable fields in the lookup. If this is set to False then the column will display in the lookup results but can not be used to search for the record during the lookup:
- IsTrackingViewState – indicates whether the server control is saving changes to its view state (Can not be changed)
- PropertyFormat – Allows formatting to be applied to the column. Your choices are None, Phone, User, Picklist
- PropertyHeader – The name of the column header in the lookup
- PropertyName – The Entity Property the column will display.
- PropertyType – Shows what kind of data type the PropertyName represents
- UseAsResult – This is intended to define that this is the column that will show as the result, once a record is selected. If more than one column has this set to True it uses the first column with it set as the returned result.
Defining what field the lookup result is written to is handled via the DataBindings property. The specific property the Lookup uses is the LookupResultValue. This is used in conjunction with the Lookup’s Lookup Binding Mode property which can be either Object or String.
If the Lookup Binding Mode is set to String, the the field defined in the LookupResultValue will store the text value that is returned from the Lookup. For instance, if we have an Account Lookup that uses the Account Name as the UseAsResult column when you perform the lookup:
The value that would be stored in the defined LookupResultValue would be “Abbot WorldWide”. T his would of course mean that the SalesLogix Entity Property defined as the LookupResultValue would need to be a string field.
Now If the Lookup Binding Mode is set to object, the Lookup returns an Entity Object based on its Lookup Entity Name. So for instance if your Lookup Entity is “Account”, when you do a lookup the lookup control will still show the name of the Account however it will actually be returning a Sage.Entity.Interfaces.IAccount object. This means that the LookupResultValue binding must be to an Entity Property that represents a matching IAccount object.
In the sample lookup above showing Abbott WorldWide, hyperlinking is enabled so that on clicking the lookup result the user navigates to the Entity defined by the lookup type. To enable this you need to set the Lookup’s Enable Hyperlinking property to True. This property will only work when the Binding Mode is object.
There are two ways that you can set the lookup control to only show a subset of records in the Lookup. Using Seeding or Using Lookup Prefilters.
Seeding allows you to bind a restiction to the grid. For instance on an Activity screen you might want to have the user define the Account the activity is for and from there have a lookup of all of the contacts only at the selected Account. You can do this by binding the Contact lookup’s SeedProperty to “Account.Id”. Now this would mean that the Contact Lookup is restricted to only show contacts where the Account.Id property is equal to the one defined by the current Activity entity.
The other alternative is to hard code a lookup to only show results that match a one certain criteria. For instance lets say we want to show an Account lookup and only allow lookups of accounts with a type = “Dealer”. We can go into the Lookup’s Lookup PreFilters collection and define this.
Now you can add multiple Prefilters together but doing so is like using an AND condition. So for instance you could further restrict to show only accounts with a type = “Dealer” and status = “Active”. So pretty cool but what about if you want to do multiple conditions? For instance wanting to show accounts where the Type = “Dealer” or Type = “Distributor”. No can do, well at least with the lookup control inherently. But fear not! It is possible! In my next blog post I will show you how.
Hopefully this little overview has helped out with the lookup control. Stay tuned for how to do multi selection criteria with lookups. That should be up within a week.