Bind two BOs


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Scott,



If I understand your situation, I'd try this:



1. drop your crm bo on the form

2. drop a SFSUsersBO on the form

3. Bind the controls to the crm BO.

4. If you are using a MaintenanceFormToolStrip, turn off edit/add/delete/save-undo, allow only navigation and browse dialog (if you are using it).

5. Add a new button to the toolstrip or a button on the form to save the user.

6. When the user clicks on this new save user button, in code, you probably would do:

a) verify that this user hasn't already been added (could skip if you are populating the crm bo based on users not added already)

b) call .Add on SFSUsersBO

c) copy data from you crm BO to the SFSUsersBO. I.e. crmBO.UserName = SFSUsersBO.us_name, doing any data transformation needed

d) call .Save on the SFSUsersBO

e) potentially update the UI or display a message to let the users know it was saved.



This way you are simply talking between two BOs, keeping the UI out of it. One BO is presented to the user so they can make decisions, the other is were the data gets added. All SQL is encapsulated within the BOs and you don't have to redo it here. The actual data access to add a new user to the SF security system is not trivial if you tried to add one manually using sql in any case (they use an encrypted field to hold a bunch of sensitive info, like password, password history, etc.). The SFSUsersBO is far easier to work with.



I hope this helps!
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
Scott,

I am a bit confused on your post when you are referring to the BOs being bound and the "search."  Are you using a BrowseDialog as your "search" or something you have created that is just a form with BOs dropped on it.  Secondly, you mentioned copying data into the SFSUsers BO...if you are copying in a DataTable then you are going to have issues with this BO.  If you manually use the Add and the wrapper properties on the SFSUsersBO then you can create a new SFSUsers record successfully.

If I understand you correctly, then everything that you want to do can be done, I just think you may be going at it the wrong way.  Sorry for the ambiguous post Ermm

Scott Hershberger
Scott Hershberger
StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)
Group: Forum Members
Posts: 10, Visits: 26
I found the best way to go around this was to create hidden fields and copy values. I could be doing this totally wrong, but it appears to work. Now my issue is that when I use a BO to copy values into SFSUsers it fails. I get no errors, but nothing is inserted. What is the process for adding a new user with code.
Scott Hershberger
Scott Hershberger
StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)StrataFrame Beginner (10 reputation)
Group: Forum Members
Posts: 10, Visits: 26
I will try to explain this bizarre situation as best I can. A client has user information in a crm database. I read this data using a BO and populate a search in my application. From the search a user can be "added" to the application as an actual user. Clicking add from the search populates a form with the users info from CRM and upon hitting save the user needs to be added to the SFUsers Table. Right now the form is obviously bound to the BO I'm using to read the data from CRM. Is there a way to bind a form to different BOs based on whether a form is loading or saving? When I try to change the fields programatically it errors out. I'm trying to avoid doing any direct sql code. If this is confusing I can elaborate.
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