back to top

Using the EntityFactory to retrieve entity objects in SalesLogix 7.5

As Ryan briefly mentioned in this post, the EntityFactory allows you to retrieve entity objects from within the SalesLogix entity model.    The EntityFactory allows you to retrieve an existing entity collection or to create a new record within a collection, which you can then manipulate and then save. The EntityFactory also allows you to delete a specific entity from the collection.

Note that the EntityFactory is a member of the Sage.Platform class.  In my code samples that follow I provide samples that already include a using reference to this class.  If you do not have this type of using statement you would need to explicitly call the full class:  Sage.Platform.EntityFactory.

There are a couple of different ways to get an specific entity using the EntityFactory.

EntityFactory.GetRepository

One approach to use the EntityFactory to return a collection is with EntityFactory.GetRepository.  This method returns the entity collection you specify.  It also allows you to pass in a particular ID using the Get method, which will result in a specific record within the entity collection being returned.  Lets take a look at how to do this.  Lets say I want to get a reference to a particular Product entity using its IProduct collection.  I can use the following line of code to create a new IProduct reference called fxproduct which refers to the IProduct result returned from the EntityFactory.GetRepository method:

IProduct fxproduct = EntityFactory.GetRepository<IProduct>().Get(productID) as IProduct;

Now with my reference established I can use my fxproduct entity reference, such as:

IProduct fxproduct = EntityFactory.GetRepository<IProduct>().Get(productID) as IProduct;

double? myProductsPrice = fxproduct.Price;

Conversely, you could combine it into one line like this:

double? myProductsPrice = EntityFactory.GetRepository<IProduct>().Get(productID).Price;

If you wanted you could just return an entire entity collection (in my example, all products in the system) using the code above and omitting the Get method:

IProduct fxproduct = EntityFactory.GetRepository<IProduct>() as IProduct

EntityFactory.GetByID

Another very similar way of using the EntityFactory to return a entity collection to to use GetByID.  This is almost identical to the GetRepository method shown above, when used in conjunction with the Get method.  This call is specifically designed to return just one record in the entity collection.  To get my reference to the Product entity as I did before it would look something like:

IProduct fxproduct = Sage.Platform.EntityFactory.GetById<IProduct>(productID) as IProduct

 

EntityFactory.Create

This method allows you to create a new entity within the collection you pass in.  To use this you can just specify which entity you wish to create a new item within:

IProduct newProduct = EntityFactory.Create<IProduct>();

This method simply creates an empty shell.  You are responsible for then filling in the entity, either in code on the page or by using the entity’s business rules.  to fill it in you can use code such as:

IProduct newProduct = EntityFactory.Create<IProduct>();

newProduct.Price = 12.00;

newProduct.Name = "A new product";

newProduct.Save();

EntityFactory.Delete

This method allows you to delete a specific record with the entity collection.  To use this you pass in the entity item to delete:

IProduct fxproduct = Sage.Platform.EntityFactory.GetById<IProduct>(productID) as IProduct

EntityFactory.Delete(fxproduct);

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Kris Halsrud
Kris Halsrud
Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos