Error when programmatically adding a new business object link record


Author
Message
PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
I'm obviously missing something, but I can't seem to add a record to a business object programmatically. I have the following code segment:





ContactRoleLink.PrimaryKeyIsAutoIncremented = false;

ContactRoleLink.NewRow();

ContactRoleLink["ID_CON"] = aContactId;

ContactRoleLink["ID_RL"] = Int32.Parse(ctlDropDown.SelectedValue);

ContactRoleLink["IND_STS"] = ctlRadio.SelectedValue;

ContactRoleLink.Save(true, "ContactRoleUpdate");





When it attempts to access the ID_CON attribute, I get a business layer exception that there is no current row. I've also tried calling the Add() method after creating the new row and calling the Add() method instead of creating a new row. Both blow up at the same location.



I do realize there are flags in the Business Layer Link Manager (BLLM) object that indicate a link row should be added when a new row is added to table 2, however because of the way this page is constructed and this particular relationship, it's not an option. It does, however seem to be related to the BLLM object. I'm able to add a link programmatically to a different link business object using the same code as above (with a different link object substituted for ContactRoleLink).



I'm going to bring up the subject of documentation again because it's something that would be very helpful in determining exactly what one should do. Simple examples can only go so far, especially when trying to figure out how to implement something like the BLLM -- it's really useful, but only if I know how it will be affected by my changes and seems even more relevant now that I believe I've tracked the source of my problem to something having to do with the BLLM.
Replies
PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
Any info on my question from the previous post?



"Shouldn't it be ignoring this link since I removed it after I populated my objects or is it still persisting somehow and being implemented when I try to add a new row?"



Thanks!

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Are you doing anything within the Global.BllManager.Remove("ContactRole") to unset the business objects on the Table1 Table2 and TableLink properties?  If you aren't then even though the object is removed, it still has references to the business objects and it still has handlers on the business object events to tell it to fill/filter again.
PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
Ben Chase (10/02/2007)
Are you doing anything within the Global.BllManager.Remove("ContactRole") to unset the business objects on the Table1 Table2 and TableLink properties? If you aren't then even though the object is removed, it still has references to the business objects and it still has handlers on the business object events to tell it to fill/filter again.




No, I was just calling a remove. I thought that would do the equivalent of unsetting the attributes. Would setting the Table1, Table2, and TableLink properties to null be sufficient?



Thanks!

PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
Well, I've got it working now. Here's my learnings:



1) Don't use the BLLM to manage a fixed M2M relationship (i.e. three controls or sets of controls that add an M2M relationship when they contain values).

2) Always run a save after making a call to DeleteCurrentRow() on a business object because even if you call it with no parameters, it only marks them as deleted.

3) When you want to remove an M2M link, set Table1, Table2, and TableLink properties to null before destroying the relationship.

4) Make sure an Undo() is called any time an exception is thrown or it will cause some interesting issues when you try to add a row the next time through.

5) Make sure there's adequate documentation about an object before using it in an application.



Item #3 is definitely a bug. If you destroy the variable managing a relationship, it shouldn't longer fire any more events for the relationship.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
PeterA - 18 Years Ago
PeterA - 18 Years Ago
Trent L. Taylor - 18 Years Ago
PeterA - 18 Years Ago
Trent L. Taylor - 18 Years Ago
                         I might be able to set up a Webex meeting (basically you would be able...
PeterA - 18 Years Ago
                             From looking at the exception details, the BLLM is trying to set the...
StrataFrame Team - 18 Years Ago
                                 I tried what you suggested and I'm having no luck. I'm not sure the...
PeterA - 18 Years Ago
PeterA - 18 Years Ago
             Are you doing anything within the...
StrataFrame Team - 18 Years Ago
PeterA - 18 Years Ago
                     Well, I've got it working now. Here's my learnings:

1)...
PeterA - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search