back to top

Using the EntityHistoryService to Retrieve Previously Accessed Entities

There are many ways to get the “current” account in SalesLogix Web. For those coming from developing for the SalesLogix Windows client, you’ll likely want the same capabilities that the BasicFunctions CurrentAccountID provides. In the web platform, however, there is all of that, plus more.

If your QuickForm or SmartPart is a child of the Account entity, you can reference the parent account instance using GetParentEntity:

Sage.Entity.Interfaces.IAccount account =
    (Sage.Entity.Interfaces.IAccount)this.GetParentEntity();

If the parent of your SmartPart is an account (meaning your SmartPart is on an entity page for type IAccount), then that will get it for you just fine.

Another option, which is a bit more limited, is to get the parent account for the current entity instance. This will, of course, only work if your current entity instance has a parent account. For example, let’s say your on a Contact-level SmartPart and you want to get the parent account:

Sage.Entity.Interfaces.IContact contact =
    this.BindingSource.Current as Sage.Entity.Interfaces.IContact;

if (contact != null)
{
    Sage.Entity.Interfaces.IAccount account = contact.Account;
    //...
}

This works great if you have a parent account for the current entity instance. Let’s say that you create an entirely new area for the client and you’d like to default the account to the current account (or really the last account the user visited) when creating new instances of your entity. The Sage Platform provides an Entity History Service for just this purpose. In the sample code below let’s grab a reference to the last account visited:

// First access the EntityHistory service
Sage.Platform.Application.IEntityHistoryService entityHistoryService =
    Sage.Platform.Application.ApplicationContext.Current.Services.Get<IEntityHistoryService>();

// Now let's use it to get the ID of the last Account accessed
string accountId = entityHistoryService.GetLastIdForType<IAccount>().ToString();

// And get a reference to the entity
IAccount account = Sage.Platform.EntityFactory.GetById<IAccount>(accountId);

You can also use that service to to back much further, beyond just the last entity accessed, but all the past ones accessed. Let’s say you want to get a list of all previously accessed accounts:

List<string> accountlist = new List<string>();
foreach (EntityHistory entity in entityHistoryService)
{
    if (entity.EntityType == typeof(IAccount))
    {
        accountlist.Add(string.Format("Accessed {0} ({1})", entity.Description, entity.EntityId));
    }
}
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
Ryan Farley
Ryan Farleyhttps://customerfx.com/article/author/ryanfarley/
Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 COMMENT

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