7/5/2025 3:30:46 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Error when creating new Association Entity
Posted: 02 Jul 09 9:43 AM
|
Basically I am creating a new Contact and an Association, when I hit the save button it works fine it saves the new Contact and the Association but right after a dialogbox is displayed, it reads :
Exception has been thrown by the target of an invocation.: The argument component cannot be null. Parameter name: component
then I close the "Add" form and I can see that all information was inserted successfully, this is my code:
IC_EmployeeDetails EmployeeDetails = form.WorkItem.Services.Get().GetEntity() as IC_EmployeeDetails;
IContact contact = (IContact)form.CurrentEntity; contact.Account = EmployeeDetails.Contact.Account; contact.AccountName = EmployeeDetails.Contact.AccountName; contact.Type = "typehere"; contact.Save();
IAssociation association = EntityFactory.Create(); association.BackRelation = "Dependent"; association.ForwardRelation = "Beneficiary"; association.FromId = Convert.ToString(EmployeeDetails.Contact.Id); association.ToId = Convert.ToString(contact.Id); association.BackNotes = null; association.IsAccountAssociation = false; contact.Associations.Add(association); contact.Save(); association.Save();
If I remove the code where it is saving the Association Entity the error is not displayed anymore.
Any Ideas ?
Thanks |
|
|
|
Re: Error when creating new Association Entity
Posted: 02 Jul 09 9:52 AM
|
I typically save the child object before assigning it to the Parent collection. Try the following:
association.Save(); 'While in debug, stop after the save and see if the record made it into the Database.
'Then add it to the Contact's collection: contact.Associations.Add(association);
'Unless you have changes to preserve at the Contact level, I don't think that you need to invoke a Contact.Save() contact.Save(); 'Try skipping this step on the debugger and see if that clears the error while adding the association to the grid and the DB. |
|
|
|
Re: Error when creating new Association Entity
Posted: 02 Jul 09 10:09 AM
|
I moved association.Save(); as suggested, just after this was executed I checked the DB and the record was there, then I added it to Contact's collection (and also tested not adding it to the collection), I removed contact.Save(); but I am getting same error.
|
|
|
|
Re: Found out - Error when creating new Association Entity
Posted: 07 Jul 09 8:49 AM
|
I got it working, I found out the problem, right after I save the entity I am trying to use one of the Parent Properties (Relationship) but this is null, it is after page does some auto-refresh that the entity loads the data in the Parent Properties, right now I am just making sure "property != null" then use it.
Is there any way to have the entity to refresh itself after being saved ?
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|