User login event

Viewed 66

I would like to run some "start-up" procedures whenever a user logs into or switches a tenant. Is there a graph I can extend to do this or some other event I can subscribe to?

And is there something similar when a user switches company/branch?

I understand that we should not add significant performance loads to such events.

2 Answers

Probably the closest you could come to this is

  1. Create a custom setup page that isn't available in the sitemap
  2. Set this page as the 'Home Page' for all of your users
  3. Add some RowSelected() event that will execute some code.

This is what I have come up with, question is: Why do I feel so dirty when I read my code? :)

Can anyone tell me if there is a reason to NOT do this?

Thanks Yuriy Zaletskyy for your blog mentioning PXGraphExtension<PXGraph>, it helped me to collect a lot of useful information.

public class SMAccessPersonalMaint_Extension : PXGraphExtension<SMAccessPersonalMaint>
{
    #region Properties
    public static bool IsActive() { return true; }
    #endregion

    #region Event Handlers
    public delegate string GetUserTimeZoneIdDel(string userName);

    [PXOverride]
    public virtual string GetUserTimeZoneId(string username, GetUserTimeZoneIdDel baseMethod)
    {
        //Do some startup stuff
        return baseMethod(username);
    }
    #endregion
}
Related