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
Sorry, I should have double-checked my code segment before I posted that. Here's an updated one:





ContactRoleLink.PrimaryKeyIsAutoIncremented = false;

ContactRoleLink.Add();

ContactRoleLink.ID_CON = aContactId;

ContactRoleLink.ID_RL = Int32.Parse(ctlDropDown.SelectedValue);

ContactRoleLink.IND_STS = ctlRadio.SelectedValue;

ContactRoleLink.Save(true, "ContactRoleUpdate");





I still get the same error. Also, here's the stack trace that I pulled from my log files:





at MicroFour.StrataFrame.Business.BusinessLayerLinkManager.HandleTableLinkSetDefaultValues()

at MicroFour.StrataFrame.Business.BusinessLayer.SetDefaultValuesEventHandler.Invoke()

at MicroFour.StrataFrame.Business.BusinessLayer.raise_SetDefaultValues()

at MicroFour.StrataFrame.Business.BusinessLayer.OnSetDefaultValues()

at MicroFour.StrataFrame.Business.BusinessLayer.NewRow()

at MicroFour.StrataFrame.Business.BusinessLayer.Add(Boolean CheckSecurity)

at MicroFour.StrataFrame.Business.BusinessLayer.Add()

at Payless.Sourcing.MaterialsManagement.EditSuppliers.SaveContactRoles(Int32 aContactId) in I:\PSS Design\Visual Studio\Materials Management\MM_UI\Suppliers\edit.aspx.cs:line 384





And the actual exception message:





BUSINESS LAYER EXCEPTION: An error occurred while setting the appropriate values on the new TableLink row.

INNER EXCEPTION: Index 0 is either negative or above rows count.


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.
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