Changing PrimaryBusinessObject using Code


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Let's assume I have 2 Tables with the following Fields:

Dogs
PK int
Name varchar(50)
Age int

Cats
PK int
Name Varchar(50)
Age int

I want to create one (1) SF Mainteance form to edit the above tables.

Let's assume a user selects Dogs to edit and I want to load the Maintenance form using Dogs as the PrimaryBusinessObject and if that same user had selected Cats the same form would be used but the PrimaryBusinessObject would be Cats.

Since the table structure is the same if there is a way to get this to happen one would only have to create one maintenance form instead of two. I would hope the toolbar would also work. Just curious about this since I have a very simple project that could use this procedure.

TIA.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Yes you can use the form's PrimaryBuisnessObject for this case, I have done the same and it works just fine, I have to say that I do not use the Maintenance Form ToolStrip, but it should also work.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Thanks so much. How do you move thru the table if you don't have a toolbar or buttons? Also, where do you set the primarybusinessobject? In the formload? 
Thanks for your help.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

In the form I am using the PrimaryBusinessObject (PBO) I am using a TreeView control, so no the navigation is done through an event of the TreeView control.  In my case I always load data for a date range period (ex: LastWeek-Today, or This Month, etc.) then I have a panel manager with some controls based on the particular table I want to show the data, Ex: Page1=BO1 and Page2=BO2, in the Activate of Page1, I set the Form.PrimaryBusinessObject to BO1 and so for the Page2, etc.

The trick is to know which event to use so you can change the PBO accordingly, it take a trial an error, but it does work pretty good and keep some methods generic, because you can always make reference to the PBO.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Thanks for the info.
I pretty much have it working showing the different data but now I was trying to use a browsedialog to search for the correct person but what I want to search on is a custom field but they don't seem to work in a browsedialog. I guess that makes sense.? Does a listview allow custom fields?
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Terry Bottorff (10/11/2011)
Thanks for the info.
I pretty much have it working showing the different data but now I was trying to use a browsedialog to search for the correct person but what I want to search on is a custom field but they don't seem to work in a browsedialog

Well I don't think I ever used a Custom Field Property in a browse dialog, even though that field would be kind of virtual to the table, but the browse dialog have several events you can handle and manipulate its query object to get what you want.

Does a listview allow custom fields?

Yes.  Custom Field Properties (CFP) are great concept and works pretty well, but you should also be very careful about constructing them.  For example, in a listview you may have a ProductID foreing key field and you want to show ProductName instead, you can create a CFP to go search the product tables and return the product name, but if you have several hundred/thousand records, it could slow down the listview record loading.
What I do is that I create my CFP like cfp_ProductName, then I use a stored procedure with a well constructed JOIN condition to bring a column with name cfp_ProductName that matches the name of the CFP in the BO, this way, the data will be there.  Of course you have to look at the CFP as read only virtual fields.
Bottom line is that CFP are excellent helpers and today I cannot program an SF application without them.  Oh by the way, I am using DevExpress reports and above technique works great for getting the data for the report and been able to see and use the CFP in the type editors of the report is just great!

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I use stored procedures to include the CFP so I feel I am doing that part correct. Also, I use XtraReports and have used CFP in them also. I agree without CFP's the work required would be much more difficult. I wish there was somewhere where all that use XtraReport and SF could discuss the how they accomplish some of the basic steps required for most reports. Just a thought.

Thank you so much for your help.
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