Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, June 30, 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: EntityFactory.Create
Andrew James
Posts: 51
 
EntityFactory.CreateYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: EntityFactory.CreateYour last visit to this thread was on 1/1/1970 12:00:00 AM
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

[Reply][Quote]
Andrew James
Posts: 51
 
Re: EntityFactory.CreateYour last visit to this thread was on 1/1/1970 12:00:00 AM
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?
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: EntityFactory.CreateYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: EntityFactory.CreateYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[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): 6/30/2025 5:11:04 AM