Join a Table with a BuisnessObject


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Wondering if there is a simple way of joining a Business Object with a table, and create a new business object. Scenarion is as follows:

1. I Fill a BusinessObject
2. I process the BusinessObject and do various calculations on the Business Object
3. When Processing is finished I want to 'Join' the BusinessObject with another few Tables, to get some additional fields
   (Dont particulalrly want to do the joins at 1 above as I dont want all the baggage when I am processing the BO

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

Processes 1 and 2 are straight forward, you have done it. Now to join fields from other tables, even though I have no clue about the situation, I guess I would create custom fields on my original BO and when ready I would enumerate the other table's records, find the appropriate place for them on the original BO and update the custom fields.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. Many thanks for reply.

This has set me in the right direction, and I can create the Custome Fileds in the origina BO. Its the 'Joining' of thsi BO to the Tables I then am not sure about

.......I would enumerate the other table's records, find the appropriate place for them on the original BO and update the custom fields.

How would I go about 'Emumerating' the Tables records, and then 'Updating' the Custom fields. Is there any construct in SF where I can use one of the Fill Methods with a string like "Select * from MYBO join Table1 on MyBOKey = Table1Key".

Just thinling out loud, one way would be to select the Tables I want to Link to , into BO's , and then doing a Seek or a SeekToPrimaryKey from my original BO to the New BO's, and if the find is true, update the Fields in this way. Doing it this way seems a bit longwinded though,  and perhaps slower than if a Join could be done directly to the Database ??
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
First, you can enumerate BOs by calling the GetEnumerable() method:


foreach(MyBO bo in myBoInstance.GetEnumerable())
{
    //-- At this point, you have the bo instance on the right record so you can access it like this
    string x = bo.FieldNameHere;

   //-- If you want to access a custom field that you HAVEN'T created a custom property for, then just access the current row
   string y = (string)bo.CurrentRow["CustomFieldNameHere"];
}

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Trent. Many thanks for replying.

Ok, I see how to Enumerate. Any ideas on the most efficient strategy to get at the data from the other Tables after I have done all the Processing stuff on the Min BO.
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 Ger,

SF Business Object are very powerful and flexible at the same time.  By the default when using the Business Object Mapper (BOM) the BO will have all fields mapped to your table, but when you are filling the BO with your own SELECT statement, whatever data structure you get, it will be reflected in the datatable in the BO, so if you have a BO mapped to a Customer table with 2 fields ex: FirstName and LastName and you fill it with SELECT * FROM Customer, the  BO.CurrentDataTable will have just those 2 fields, but if you fill it with a JOIN SELECT, and this has another field like CompanyName, the BO will have access to FirstName and LastName via their properlies, but the BO.CurrentDataTable will also have a column named CompanyName which you can access it by either creating a CustomFieldProperty in the BO or by using BO.CurrentRow.Item("CompanyName")

I don't quite understand what your goals is, but as you can see, there is a lot you can accomplish with the BOs.

Edhy Rijo

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)Advanced StrataFrame User (654 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy, Thanks for replying.

I'll give an example of what I am trying to do ,by way of illustration

I have  a Table, with say a Million records, with StockCode,CustCode,SupplierCode,Fielda,Fieldb,Fieldc,Fileldd

I want to add Fielda+Fieldb+Fieldc+Fieldc to Get Fieldx.

Ok, I run down through the BO and do the various calculations. This data is to go out to a report, along with The Customer name, Stock Name and  Supplier Name , these are all taken from additional Tables, linked to my Primarty BO by means of say a Primary Key. (In reality, there would not be 3, but perhaps 20 lookup fields that I would need to lookup from my Main Business Object from other tables using Primary Keys or similar).

I think there are proabably two ways to do this:

1. Join ALL the tables to start with, I then end up with the Million Rows, but with a lot of additional 'Bloat', that I am going to be processing as I do the calculations (i.e. traversing down the Business Object)

2. Just select out the 7 fields , as above , and add in the Lookup's to the other tables as a separate piece of code, after the procerssing has been done.

Of the 2 ways outlined above, I am concerned that perhaps Option 1 is not going to be very efficient, as I am 'Carrying' all the Bloat as I am 'processing' the BO. I would have thought that Option 2 (or something similar) would have been a more efficient way of processing as I only 'Append' in the additional data , when I need it, just at the end....and hence my initial question... whats the best and most efficient way of doing this in a StrataFrame environment  
Michel Levy
Michel Levy
StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)StrataFrame User (449 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Hi Ger,

not sure it is the best solution, but what you ask may be done with QueryAdataset (http://www.queryadataset.com/). a very powerfull tool, which allows you to join the data of a BO with an external datatable, the result will be a datatable that you may import in a BO, or use for whatever you need.

Powerfull and cheap (200$, royalty free).
Andrew Harper
Andrew Harper
StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)StrataFrame User (282 reputation)
Group: StrataFrame Users
Posts: 87, Visits: 3.3K
Hi Edhy,

<< the BO will have access to FirstName and LastName via their properlies, but the BO.CurrentDataTable will also have a column named CompanyName which you can access it by either creating a CustomFieldProperty in the BO or by using BO.CurrentRow.Item("CompanyName") >>

I didn't realise this - thanks for the tip.

All the best for Christmas and the New Year,

Andy



 
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 Andy,

You are welcome and happy holidays to you too!

Edhy Rijo

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