Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, July 5, 2025 
 
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!
 Web Forums - SalesLogix Web Platform & Application Architect
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.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Error when creating new Association Entity
Alberto R
Posts: 9
 
Error when creating new Association EntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Error when creating new Association EntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.
[Reply][Quote]
Alberto R
Posts: 9
 
Re: Error when creating new Association EntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.


[Reply][Quote]
Alberto R
Posts: 9
 
Re: Found out - Error when creating new Association EntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
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 ?
[Reply][Quote]
 Page 1 of 1 
  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!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/5/2025 4:15:12 PM