SmartSelect datasource with Foreign Fields issue

Posted by pauldownie on 03-Nov-2009 11:40

Hello,

I am having an issue with a smartSelect that uses a foreign field. I have found that when I link the smartSelect's SDO to one linked to that of the smartSelect's containing viewer, under certain conditions (see below) the value in the smartSelect's underlying field will not be displayed in the smartSelect despite the value being present in the smartSelect. If I remove the link, that condition goes away, but of course I am left with more values than should be available in the smartSelect. I have been following the P3572 KB "How to drive a SmartSelect datasource with Foreign Fields from a parent SDO", but am a little confused about the suggestion to subscribe to "browseValueChanged". There is no mention of publishing that event anywhere and it doesn't seem to be necessary (at least in my case) as I have already created a data link which responds to the dataAvailable event.

The "certain conditions" are each time a new record is selected at the highest order of five linked SDOs. The initial record four linked SDOs away will show a blank value in the smartSelect even if the underlying field has a value that is present in the smartSelect. Navigating to a new record in any one of the four lower linked SDOs will cause the smartSelect to show the correct value.

I have tried moving addLink and setForeignFields to a postCreateObjects procedure but it didn't help.

Any ideas what the problem is and how to resolve it?

thanks,

Paul

Progress v 9.1E04

Win XP

All Replies

Posted by Håvard Danielsen on 03-Nov-2009 15:27

The "certain conditions" are each time a new record is selected at the highest order of five linked SDOs. The initial record four linked SDOs away will show a blank value in the smartSelect even if the underlying field has a value that is present in the smartSelect. Navigating to a new record in any one of the four lower linked SDOs will cause the smartSelect to show the correct value.

It's a bit unclear how you select a new record at the highest order. If this is done through a SmartSelect while the Viewer is enabled then it may actually be expected behavior, since you in effect are updating and we do not choose a child record per default. If, on the other hand, the child SmartSelects are not refreshed when you navigate the Viewer's data source then this may be a bug (or setup problem...). If you provide a more detailed explanation of the involved components and links then we might be able to assess whether this should work or not. But also narrow down the problem to the minimum number of involved components. (From your description it sounds as the problem would be present with 2 SmartSelects)

Posted by pauldownie on 03-Nov-2009 16:58

Hi Havard,

I hope this helps to explain my situation.

The record selection at the highest order I am referring to is done through a browse. This is not an order based application but to use that analogy it would be like selecting a customer from a browse on the first tab of a smartFolder and having the smart select for an attribute of an item in the orderLine tab show an incorrect blank value. Navigating to a different order or orderLine would get the smartSelect working but would reoccur for each new customer selected: on selecting a different customer the first order of that customer would also be selected as would the first orderLine of that order, and the smartSelect would show an incorrect blank value.

In the main window I have five SDOs each with a one to many relationship to the next one:

sdoA -> sdoB -> sdoC -> sdoD -> sdoE
or sort of like
customer -> order -> orderLine -> item

Each SDO is data linked to one of five frames each on their own tab in a smartFolder.

Each folder has at least one smartViewer, a smartToolbar, and a smartBrowser.

The frame in the fifth, or lowest order, tab has a smartViewer that contains the smartSelect that isn't working quite right. This smartViewer holds the smartSelect and its SDO and is data linked to its container (smartFrame) which is liked to sdoE. I have code in the initializeObjects override in the smartViewer to link the smartSelect's SDO to the data source of the data source of the smartViewer (sdoD). The foreign key for the smartSelect's SDO is available at the top level (sdoA) and is present as a database field in sdoB but has been defined as variable and populated through a function within the SDO for sdoD. I have tried linking the smartSelect's SDO to sdoA or sdoB instead of sdoD but still get the same result.

Any ideas?

thanks,

Paul

Posted by Håvard Danielsen on 04-Nov-2009 07:07

There is a potential timing issue when a combo-box SmartSelect SDO and its Viewer have the same data source. If the parent’s publish of dataAvailable reaches the Viewer before the SDO then the screen-value of the combo will not be set since the combo list-items has not been refreshed with the corresponding data yet.

It’s not at all certain that this is your problem, since it works in some cases, but this could be because the data link deactivate/activate kicks in and fixes the problem when you change pages.

One way to deal with this problem is to override dataAvailable in the Viewer as follows:

procedure dataAvailable:

    define input parameter pcRelative as character no-undo.

    /* ensure smartselect combo is filled before display */

    run dataAvailable in sdoE (pcRelative).

     /* Tell the sdo to ignore the next dataAvailable

     (from the SDO) if ForeignFields is unchanged

     (avoid filling the smartselectcombo again) */ 

    {set DataIsFetched true sdoE}.

    run super(pcRelative). 

end.

Posted by pauldownie on 04-Nov-2009 09:42

Thanks Havard, but still no success.

I placed run dataAvailable code into the dataAvailable override in the smartViewer but am now getting the "-s exceeded" (5635) error. Is it possible this is creating an infinite loop even with setting DataIsFetched?

I have also tried turning on and off the activate/deactivate targets on reposition toggles but to no effect.

Posted by Håvard Danielsen on 04-Nov-2009 09:45

Try it without setting DataIsFetched. It will still work (if that is your problem).

What is the stack trace for the -s error? 

Posted by Håvard Danielsen on 04-Nov-2009 09:48

Are you sure you are calling DataAvailable in the SmartSelect's SDO?

Posted by pauldownie on 04-Nov-2009 10:27

Sorry, I had interpretted your note to suggest the dataAvailable override was to go in the viewer. I have placed the code in the smartSelect's SDO now but am still getting error messages ("Ditem is not large enough to hold string" (4043), "publish statement failed" (6480) and "-s exceeded" (5635)) and other issues with the display including the absence of any records in the browser on the final tab. The smartSelect shows the correct value. However the values in the smartSelect have not been filtered. The same result can be achieved by removing the setForeignFields function.

Posted by Håvard Danielsen on 04-Nov-2009 10:30

You must override the Viewer's dataAvailable, but call dataAvailable in the SmartSelect SDO and set DataIsFetched in this SDO as well. You should have the handle to this SDO available as h_ in the Viewer source code.  My code example uses sdoE, since I think this was the name you used in your description.

Posted by pauldownie on 04-Nov-2009 10:37

Oh, I meant to say something about the "Publish statement failed" error (PUBLISH statement failed. Procedure win/provenience/fsuboper.w has no entry point for dataAvailable. (6480)). The error references the frame that is supplied data from sdoD instead of sdoD. This is strange. I am using getDataSource to give me the handle to use in the run dataAvailable statement. A check on that handle using message hDataSource:file-name showed it to be the correct SDO and not a frame, so the message seems strange to me.

Posted by pauldownie on 04-Nov-2009 10:45

Yes that makes more sense and seems to be working just fine now.

Many thanks,

Paul

This thread is closed