1. Tracy Lamb
  2. PowerBuilder
  3. Thursday, 7 April 2022 13:13 PM UTC

Hi all,

I'm testing linkage service in PB2021 with latest PFC.  I inherited a new window from w_sheet and copied the code from the PFC example (w_linkageretrieval) and changed the dws and retrieval arguments.  Can't get it to work to save my life.  So I exported w_linkageretrieval from the PFC example app, and imported it.  Changed the dws and retrieval arguments, just as I did in my new window, and that works. 

I noticed w_linkageretrieval inherits from w_main, whereas I created my window by inheriting from w_sheet.  Is there a difference between the two windows that would prevent linkage service from working correctly in w_sheet?

TIA,

~~~Tracy

 

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 7 April 2022 15:52 PM UTC
  2. PowerBuilder
  3. # Permalink

Tracy -

I believe the problem is caused by the order in which dw_1 & dw_2 are created in the w_test_link window. Because the Linkage service configuration is being performed in each DW's Constructor event, the proper setup is not executing in the order it should.

In the example window, the "parent" DW (dw_cust) gets created first, then the "child" DW (dw_sales). In your window, the order is reversed (dw_2, the "child" DW first, then dw_1 second). Look at the order in which controls are created in the exported source of both windows.

This is why I prefer to place all of the Linkage configuration in the window's pfc_PostOpen event, and this is what i suggest you do, also. Here is how I recommend you try changing the code in w_test_link:

//-------------------------------
// dw_1 Constructor event script:
//-------------------------------

this.of_SetUpdateable( FALSE )

//-------------------------------
// dw_2 Constructor event script:
//-------------------------------

this.of_SetUpdateable(false)

//-------------------------------
// w_link_test pfc_PostOpen event script:
//-------------------------------

dw_1.of_SetLinkage(True)
dw_2.of_SetLinkage(True)

// Link this detail datawindow to it's master.
dw_2.inv_linkage.of_SetMaster(dw_1) 

// Specify the columns that link the two DataWindows.
// The values in these columns will be used as retrieval arguments. 
dw_2.inv_linkage.of_Register("type_id", "price_type_id") 

// Specify how column links will be used...
// in the case, as retrieval arguments 
dw_2.inv_linkage.of_SetStyle(dw_2.inv_linkage.RETRIEVE) 
dw_1.inv_linkage.of_SetStyle(dw_1.inv_linkage.RETRIEVE)

See if this corrects the issue for you. I hope it helps.

Comment
  1. Tracy Lamb
  2. Thursday, 7 April 2022 16:19 PM UTC
My goodness... this solved the problem! I've been working on this for over 3 days now... I can't thank you enough for your advice and taking time to review the source code.

Hugs and Kisses!

~~~Tracy
  1. Helpful
  1. Tracy Lamb
  2. Thursday, 7 April 2022 16:23 PM UTC
I need to add row services and query services as well, should I do all of that in window's pfc_postopen event?

  1. Helpful
  1. John Fauss
  2. Thursday, 7 April 2022 18:20 PM UTC
Aw, shucks.

That's terrific news, Tracy!



My approach has always been two-fold:

1. If a service/feature affects only a single DW (or another visual control), then the control's Constructor event is where the service should be enabled and configured.

2. If multiple controls are affected (such as this Linkage example or the Resize service). then somewhere in the window open event sequence (pfc_PreOpen or a custom, dedicated invoked from the pfc_PreOpen event for Resize service configuration, for example) or pfc_PostOpen.
  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 7 April 2022 14:07 PM UTC
  2. PowerBuilder
  3. # 1

Attached is the exported code for w_link_test (the one that doesn't work) and w_linkageretrieve (the one that does work).  All dw's in w_link_test are descended from u_dw.

 

Attachments (1)
Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 7 April 2022 13:43 PM UTC
  2. PowerBuilder
  3. # 2

The "hooks" for the PFC's Linkage service are coded in pfc_w_master (w_master), so if the version of w_sheet your app is using is inherited from w_master (as it should be), the necessary support for the operation of the Linkage service is there.  More importantly, are the DW's in this window all descended from u_dw? They should be in order for Linkage to work, as this particular service is very closely tied into the PFC's ancestor DataWindow control and not the window in which the DW's reside.

If you set a breakpoint in pfc_u_dw's of_SetLinkage function, run the app thru Debug and open ONLY the window in question, does the Debugger stop there? If not, then the Linkage service is not properly initialized/configured in your window. I typically enable and configure the Linkage service in all of a window's DataWindow's in the window's pfc_PostOpen event. I'm not familiar with the w_linkageretrieval example window you have referred to, so I cannot speak to that.

If you are still unable to figure this out, export the source code for the window in question, zip it and attach it to a new reply. If the window is not too large/complex, I and/or others should be able to examine the exported source and hopefully provide you with some guidance. Scan the contents of the exported window prior to zipping and ensure no sensitive/proprietary info is included, please.

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 7 April 2022 13:33 PM UTC
  2. PowerBuilder
  3. # 3

Hi Tracy,

Linkage service should also work with pfc sheet window.

The only difference between pfc_w_main and pfc_w_sheet are some coded events to show MDI Microhelp if activated in application manager object.

You should debug to see whats going wrong in your example.

Regards,

René

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.