When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form


When I copy my "Search" BO used in the BrowseDialog to my "Real" BO...
Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
LOL...glad you found what you needed Smile
Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Trent L. Taylor (10/28/2008)
Yup, go into the BO Mapper, right-click the BO in question, the open the Advanced Options.  You can override the Primary Key.  This was actually implemented for this very purpose (when mapping to views).  It has other uses as well, but this is what spawned this feature.

Thanks a million, Trent! You are my hero!

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yup, go into the BO Mapper, right-click the BO in question, the open the Advanced Options.  You can override the Primary Key.  This was actually implemented for this very purpose (when mapping to views).  It has other uses as well, but this is what spawned this feature.


Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Trent L. Taylor (10/28/2008)
  1. The dialog is shown and the results captured
  2. The CurrentRowIndex is set within the BusinessObjectToPopulate (_BusinessObject)
  3. The BrowseDialogClosed event is raised

So you can see that the CurrentRowIndex should be set at this point, so as I mentioned, there could be something else going on here that I cannot see in your snippet.  A code sample always helps when trying to work through problems like this.  Let me know if this doesn't get you going in the right direction.

 

OK - I think I know what is happening here. boProspectSearch is based on a ciew so no primary key is specified in the BP mapper. Therefore, loForm.SelectedPrimary key is Nothing Tongue.

Is there a way to tell the BO mapper that a field in the view is a primary key?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You are welcome to produce a sample the replicates your behavior and post it here, but if you look at the ShowDialog method in the SF source code in the BrowseDialog class, you will see that the BrowseDialogClosed event isn't called until the index has been set, so there may be another factor here in your code.  Also, we use a technique similar to this (for other purposes) in our medical software, so I am confident that it will work, but there just may be something else in the mix here.  Here is the code that I an referring to:

(I have also attacherd this image so you don't have to squint BigGrin)

  1. The dialog is shown and the results captured
  2. The CurrentRowIndex is set within the BusinessObjectToPopulate (_BusinessObject)
  3. The BrowseDialogClosed event is raised

So you can see that the CurrentRowIndex should be set at this point, so as I mentioned, there could be something else going on here that I cannot see in your snippet.  A code sample always helps when trying to work through problems like this.  Let me know if this doesn't get you going in the right direction.

Attachments
BrowseDialog.png (127 views, 35.00 KB)
Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Trent L. Taylor (10/28/2008)
Well, I am a little confused here as to what you were expecting, but you are copying out of the CurrentDataTable after a search.  When you do this, the record pointer is irrelevant.  There is no record pointer in a data table, and when you call the CopyDatafrom method, the CurrentRowIndex is going to be reset.  So here are a couple of points:
  1. When you call a browse and it returns a record set, the CurrentRowIndex is "synced" up with the BusinessObjectToPopulate associated with the BrowseDialog (this is not part of the data table).
  2. When you call a CopyDataFrom, you will need to save off and or reposition the record pointer yourself as the CopyDataFrom will move the CurrentRowIndex when clearing and refilling. 
  3. In the BrowseDialogClosed event, the BusinessObjectToPopulate should already have the CurrentRowIndex set, so if you want to seek or reposition the BO after the copy, save off the selected PK and then scall a NavigateToPrimarykey or a SeekToPrimarykey after you call the CopyDataFrom.

The problem is that when the BrowseDialog is closed, boProspectSearch.CurrentRowIndex = 0 no matter which row in the search results grid I have clicked on and boProspectSearch.client_pk is always the client_pk from the first record in the search results grid Angry


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, I am a little confused here as to what you were expecting, but you are copying out of the CurrentDataTable after a search.  When you do this, the record pointer is irrelevant.  There is no record pointer in a data table, and when you call the CopyDatafrom method, the CurrentRowIndex is going to be reset.  So here are a couple of points:

  1. When you call a browse and it returns a record set, the CurrentRowIndex is "synced" up with the BusinessObjectToPopulate associated with the BrowseDialog (this is not part of the data table).
  2. When you call a CopyDataFrom, you will need to save off and or reposition the record pointer yourself as the CopyDataFrom will move the CurrentRowIndex when clearing and refilling. 
  3. In the BrowseDialogClosed event, the BusinessObjectToPopulate should already have the CurrentRowIndex set, so if you want to seek or reposition the BO after the copy, save off the selected PK and then scall a NavigateToPrimarykey or a SeekToPrimarykey after you call the CopyDataFrom.

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Ivan George Borges (10/28/2008)

Could it be that the record was a duplicate and didn't get copied?

That is irrelevant. The primary key on all the duplicated records would be the same Smile

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Marcia.

Could it be that the record was a duplicate and didn't get copied?

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
This code doesn't work becasue boProspectSearch.client_pk contains the PK of the first record even though I selected the 5th record in the grid. I know I should be able to do this because when I don't copy the data from the "Search" BO the form populated correctly with the selected record. So what do I need to do here?

Thanks!

private void brwProspects_BrowseDialogClosed(MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogClosedEventArgs e)

{

// Copy the data from the prospect search business object

// to the clients business object

string[] lcFieldList = new string[] { "client_pk", "type_fk", "tier_fk", "company_nme", "company_ein", "stradd_nme", "stradd_sfx", "city_nme", "state_nme", "pcode_nme", "active_flg", "sales_fk", "relat_fk", "admin_fk", "analy_fk", "file_dir", "csz_dsc", "lastmod_nme", "lastmod_dte" };

Int32 lnClient_pk;

if (!boProspectSearch.IsEmpty)

{

lnClient_pk = boProspectSearch.client_pk;

boClients.CopyDataFrom(boProspectSearch.CurrentDataTable.DefaultView.ToTable(true, lcFieldList), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable);

boClients.NavigateToPrimaryKey(lnClient_pk);

}

}

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search