Executing Code in Creatio Application and Session Start and Shutdown Events

If you need to execute custom code when the Creatio application starts up or shuts down, or when a user session starts or ends, you can easily do so by creating a class that inherits from AppEventListenerBase and overriding OnAppStart, OnAppEnd, OnSessionStart, or OnSessionEnd.

Let’s take a look at a sample class that executes some code when the Creatio application starts.

using Terrasoft.Common;
using Terrasoft.Core;
using Terrasoft.Web.Common;

namespace Terrasoft.Configuration
{
    public class CustomAppEventListener : AppEventListenerBase
    {
        protected UserConnection GetUserConnection(AppEventContext context)
        {
            var appConnection = context.Application["AppConnection"] as AppConnection;
            return appConnection?.SystemUserConnection;
        }

        public override void OnAppStart(AppEventContext context)
        {
            base.OnAppStart(context);
            var userConnection = GetUserConnection(context);

            // DO SOMETHING ON APPLICATION START HERE
        }
    }
}

Similarly, if you need to respond to a user starting a session, you can use this same approach, however, you’ll get the UserConnection from their session so you can determine the user who started the session.

using Terrasoft.Common;
using Terrasoft.Core;
using Terrasoft.Web.Common;
using Terrasoft.Web.Http.Abstractions;

namespace Terrasoft.Configuration
{
    public class CustomAppEventListener : AppEventListenerBase
    {
        protected UserConnection GetSessionUserConnection()
        {
            return HttpContext.Current.Session["UserConnection"] as UserConnection;
        }

        public override void OnSessionStart(AppEventContext context)
        {
            base.OnSessionStart(context);
            var userConnection = GetSessionUserConnection();
            var user = userConnection.CurrentUser;

            // DO SOMETHING ON SESSION START HERE
        }
    }
}

The AppEventListenerBase class has the following methods available to override:

  • OnAppStart
  • OnAppEnd
  • OnSessionStart
  • OnSessionEnd

Note, I’ve used the class name “CustomAppEventListener”, however, you don’t need to name the class this. It can be named whatever you’d like.

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.

8 COMMENTS

  1. Hi Ryan,

    Is there any Event available that can be used before ‘OnSessionStart’ event to check some condition or perform some action before validating login credentials or session-start?

    • Newer versions of Creatio do log compilations in the CompilationHistory table. You can use that to see when a compilation starts. From externally, you could also listen for the telemetry log for a compilation (I can’t remember the logger name for that, but if you listen for telemetry logs you’ll see it when a compilation starts)

    • I would assume that this object does not trigger signals (such as to start a process) since at the time this object is written to, the compilation is underway and the system and model would not be available for use. You won’t be able to use the system being compiled to respond to and do something while it’s being compiled.

      From an external application you could listen for the ConfigurationBuild or Build logger (you could use Clio command-line to get the logger telemetry if needed). See https://share.customerfx.com/L1uZLE6L

LEAVE A REPLY

Please enter your comment!
Please enter your name here

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Using the AI Prompt to Create Dynamic Folders in Creatio

Using Creatio's AI prompt to create the filter for a dynamic folder works best if you specifically ask for that, and if you are as clear and direct as possible about the filtering, conditions.

Related Articles

AI Readiness Checklist for CRM Teams: Is Your CRM System Ready for AI?

Before using AI in Creatio, make sure your CRM data, users, processes, and automation foundation are ready. Use this practical AI readiness checklist for CRM teams.

Build Your Creatio AI Skills with the 2026 AI Summer Program

Join Creatio’s free 2026 AI Summer Program to learn how to identify, build, deploy, and manage AI agents.

Creatio 10x Is Coming: Join the Webinar to Explore the Future of AI-Native CRM

Learn what's new in Creatio 10x and how AI-native CRM, agentic AI, and no-code automation are shaping the future of customer relationship management. Join the upcoming webinar and discover what's next.

Creatio Unlimited Pricing Explained: AI Packages, Costs, Pros & Cons

Learn what Creatio’s new Unlimited pricing model includes, what it doesn’t include, how AI Action packages work, and the pros and cons for businesses evaluating Creatio.

Related Videos