lookups change in 2.6

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

lookups change in 2.6

Post by czentman »

1. table = lookups.GetTable(TableName, spec) is not working in 2.6 and was in 2.5. The error received is 'GetTable' is not a member of softpro.ordertracking.client.lookups.

2. Dim value As SoftPro.OrderTracking.Common.LookupValue is no longer a defined value in 2.6

I think a bunch of changes to related to lookups. Please help. I can't stand having to re-code for every upgrade.
Hadi Chemaly

Re: lookups change in 2.6

Post by Hadi Chemaly »

Lookups went through a major overhaul in 2.6, from a 2-tier to a 3-tier service with much improved performance metrics. The changes include a remodeled Lookups Manager and a redefined Lookups API.

Unfortunately, third party code written against the 2.5 API needs to be updated to use the new lookup API. The good news is that the new 3-tier lookup infrastructure is robust, performant and flexible, and the new API is no longer expected to change in a major way (though I cannot rule out possible tweaks, hopefully non-breaking to you).

The SDK documentation has been updated to reflect the new API usage, please take a look at the HowTos --> Using the API --> Using the Lookup Tables API section.

Lookup interfaces are now in the SoftPro.OrderTracking.Client assembly. The short answers to your questions are the following:
czentman wrote:1. table = lookups.GetTable(TableName, spec) is not working in 2.6 and was in 2.5. The error received is 'GetTable' is not a member of softpro.ordertracking.client.lookups.
1. GetTable() is now replaced with QueryTable(), and the table name is now specified in the spec argument. Here is an example:

Code: Select all

Lookups lookupService = server.GetService<Lookups>();
LookupQuerySpec spec = new LookupQuerySpec();
spec.Table = "MyTableName";
spec.SchemaOnly = false;
ILookupTable table = lookupService.QueryTable(spec);
czentman wrote:2. Dim value As SoftPro.OrderTracking.Common.LookupValue is no longer a defined value in 2.6
2. LookupValue has been replaced with ILookupValue, which you can use like this:

Code: Select all

ILookupRow newRow = table.NewRow();
ILookupValue newName = newRow.NewValue(false, "Joe");
Let us know if you run into problems.
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: lookups change in 2.6

Post by czentman »

thanks. that was pretty helpful. I still don't know a way of deleting a row from the ilookuptable/ilookuprow types. Something like ilookuptable(0).delete or ilookuprow.delete. I looked in the sdk doc and didn't find it helpful. Altogether, I can't seem to find any coding snippet examples in the sdk documentation.
roteague
Posts: 292
Joined: Thu Sep 25, 2008 4:49 pm
Location: Honolulu, Hawaii

Re: lookups change in 2.6

Post by roteague »

Try something like this:

Code: Select all

            ILookupTable lookupTable = lookupSvc.QueryTable(spec);
            if (lookupTable != null)
            {
                ILookupRowCollection foundRows = lookupTable.Rows;
                foreach (ILookupRow row in foundRows)
                {
                    lookupTable.Rows.Remove(row);
                }

                lookupSvc.ApplyChanges(lookupTable);
            }
If you look at the interface, ILookupTable you will find that Rows is defined as a ILookupRowCollection, which is derived from ICollection, which contains the Remove method.
Robert
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: lookups change in 2.6

Post by czentman »

Thanks. I thought I got the code basicly "converted" but my gridview is not filling up. I just use the code to "DataGridView1.DataSource = table". Can I make a datasource for a gridview be a ilookuptable datatype? Do I have to do it another round about way?
roteague
Posts: 292
Joined: Thu Sep 25, 2008 4:49 pm
Location: Honolulu, Hawaii

Re: lookups change in 2.6

Post by roteague »

Sorry, I don't use bound controls, so I don't know much about them.
Robert
Hadi Chemaly

Re: lookups change in 2.6

Post by Hadi Chemaly »

Try binding the Rows property to your grid. You may need to write your own customized binding source, with the lookup table as data source and the "Rows" property as data member, depending on what functionality you want your grid to provide.
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: lookups change in 2.6

Post by czentman »

That seemed to help. I'm still having a hard time viewing the data in the gridview but I can see the data there. Now I'm having trouble doing the spec.filter - I don't think it's working. What's the correct syntax for the filter. Is it better to use the spec.search - I see there's a search event on the lookupqueryspec object that I'm using.
Hadi Chemaly

Re: lookups change in 2.6

Post by Hadi Chemaly »

You may use the Search property on the LookupQuerySpec object if you wish, by passing in a search string (works like Google search).

Or you may be more specific by using the Filter property to get a filtered set of rows, as such (this is from the Using the Lookup Tables API in the SDK Documentation):

Code: Select all

LookupQuerySpec spec = new LookupQuerySpec();
spec.Table = "MyTableName";
spec.Filter = "[Name] LIKE @val"; // 
spec.FilterParameters.Add("val", "c%");
ILookupTable table = lookupService.QueryTable(spec);
SQL wildcard convention is used to achieve "starts with" and "contains" functionality.

To filter on the key column, use the special name "{KEY}", as shown below:

Code: Select all

spec.Filter = "[{KEY}] LIKE @val";
Please refer to the SDK documentation for more details, and let us know if there is any specific query you are trying to achieve. I hope this helps.
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: lookups change in 2.6

Post by czentman »

That was helpful. Actually, I looked up lookupqueryspec in the sdk doc and I didn't one example of syntax like you just gave in a jiffy. Also, I'm now having a hard time converting to a cell-text to view the data on the screen. I know the data is there because I already had a routine that when you click on the cell it puts all the data into textboxes and it uses a trycast for each textbox. But I want to do that trycast on rowbound but I don't see a rowbound function or something like that.
Post Reply