How to get current user programmatically?

SOLVED

Hi all,

I see that Sage 200 have this class: Sage.Accounting.User, but how do I get the current user?

Thank you

  • +1
    verified answer

    Sage.Accounting.Application.ActiveUser is obsolete but still works, replaced by ActiveUserNumber and ActiveUserName

    But if you need the User object (eg, in POP Authorisation) you can use Sage.Accounting.Application.Users.GetUser(ActiveUserNumber )

  • 0 in reply to Geoff Turner

    Thank you Geoff. As I explore more on Sage.Accounting.Application, I ended up with the code below because I need to get the user role as well.

    Sage.Accounting.Role role = Sage.Accounting.Application.Roles.GetRole("Administrators");
    if(role != null)
    {
        foreach (Sage.Accounting.User u in role.Users)
        {
            if (u.UserNumber == Sage.Accounting.Application.ActiveUserNumber)
            {
                //hide button
            }
        }
    }