6/29/2025 11:32:56 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.
|
|
|
|
EntityFactory.Create
Posted: 09 Jun 10 4:50 AM
|
Hi all
When creating a new Contact/Account, I need to also create the leadsource for these. The account I have done but the contact Leadsource is slightly different. Am I able to use
IContactLeadSource CLS = EntityFactory.Create();
If so has anyone got code I can look at to see how it all works and what values I need. for example
CLS.LeadDate = DateTime.Now; CLS.LeadSource.AbbrevDescription = lueLeadSource.LookupResultValue.ToString();
Thanks in advance for any help given
|
|
|
|
Re: EntityFactory.Create
Posted: 09 Jun 10 9:25 AM
|
Yes you can use that, the code would be something like (angle brackets will be taken out by this site so I have replaced them with 3 quotes (''') instead):
Sage.Entity.Interfaces.IContactLeadSource cls = Sage.Platform.EntityFactory.Create'''Sage.Entity.Interfaces.IContactLeadSource'''();
cls.LeadDate = DateTime.Now; ....property setting/....
cls.Save();
contact.LeadSource = cls; contact.Save();
voila...
Off the top of my head but should be correct. Not sure about the relationship between contact and leadsource - it may be a one to many. If so something like:
contact.LeadSources.Add(cls);
Cheers, Nick
|
|
|
|
Re: EntityFactory.Create
Posted: 09 Jun 10 9:39 AM
|
Thanks for the reply Nick
I am getting the following error message
could not insert: [Sage.SalesLogix.Entities.ContactLeadSource#Sage.SalesLogix.Entities.ContactLeadSource][SQL: INSERT INTO CONTACT_LEADSOURCE (CREATEDATE, CREATEUSER, LEADDATE, MODIFYDATE, MODIFYUSER, CONTACTID, LEADSOURCEID) VALUES (?, ?, ?, ?, ?, ?, ?)]: The statement has been terminated. : Cannot insert the value NULL into column 'LEADSOURCEID', table 'SalesLogix_Dev.sysdba.CONTACT_LEADSOURCE'; column does not allow nulls. INSERT fails.
my current code is
IContactLeadSource CLS = EntityFactory.Create();
CLS.Contact = contact; CLS.LeadDate = DateTime.Now;
CLS.Save();
contact.LeadSources.Add(CLS); contact.Save();
When ever I try to add CLS.LeadSource.id or CLS.LeadSourceID it gives an error message that these are read only fields, do you know what I should be using? |
|
|
|
Re: EntityFactory.Create
Posted: 09 Jun 10 9:47 AM
|
Ah yes of course. The ContactLeadSource entity is a LeadSource and a COntact joined, so you would firstly create a LeadSource entry. I would guess by doing an a GetById..
Sage.Entity.Interfaces.ILeadSource ls = Sage.Platform.EntityFactory.GetById'''Sage.Entity.Interfaces.ILeadSource'''('THE ID OF THE LEADSOURCE YOU WANT (YOU MAY NEED TO DO A SQL/HQL STATEMENT TO GET THIS');
IContactLeadSource.LeadSource = ls
Now do the rest of the example code...
Cheers, Nick |
|
|
|
Re: EntityFactory.Create
Posted: 09 Jun 10 9:54 AM
|
Sorry your lueLeadSource.LookupResultsValue (casted as a Sage.Entity.Interfaces.ILeadSource) will give you your LeadSource entity, so no need to do the getbyid specified.
Cheers,
Nick |
|
|
|
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!
|
|
|
|
|
|
|
|