Join a Table with a BuisnessObject


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K 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 (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 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.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 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 ??
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K 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 (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 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

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