web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to log off different user with different time in Microsoft AX?

(0) ShareShare
ReportReport
Posted on by 10

Hi All,

I found the below codeby Jovan to log off all user after few minutes and upon searching also found to log off all user except admin user. However, I am looking for code to log off different user at different set time i.e for normal user 10 min, Nurse 30 min, Finance 90 min and admin no time limit. I am completly new with this code as I haven't used programming for few decades. I hope someone can help me out with my code. Thank you.

// Created on 15 October 2012 by Jovan Bulajic
static void User_Timeout(Args _args)
{
    UserInfo    userInfo;
    ;
    ttsbegin;
    while select forupdate *
        from userInfo
    {
        userInfo.autoLogOff = 30;
        userInfo.update();
    }
    ttscommit;
}

Regards,

Niresh Joshi

I have the same question (0)
  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: How to log off different user with different time in Microsoft AX?

    Which version of AX are you using? You've selected "Don't know" for some reason - do you need our help with finding it out?

    Anyway, instead o iterating all UserInfo records and setting the same value to all of them, you can find UserInfo record for a particular user and set the value for this user only.

  • Niresh Profile Picture
    10 on at
    RE: How to log off different user with different time in Microsoft AX?

    Hi Martin,

    Thank you for your reply. We have a very old version of PeoplePoint Application which is Microsoft product. In there it say Microsoft Dynamic AX 2009, Kernel Version 5.0.1500.6419

    I am not good in coding, so if you can you provide me details on how to setup value for particular user group it will be great. As I mentioned in my above post, I got that code from forum so I have zero idea on what is what though I can make some sense.

    I know how to set log off time for particular user from application but what I need is set logoff time for user with certain access group to different time. We have more than 300 users who are in nurse group only so it will be good few days for me to find out each and enter the timeout manually so want something quick and effective. Thank you.

    Regards,

    Niresh Joshi

  • Verified answer
    Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: How to log off different user with different time in Microsoft AX?

    If your goal setting the value for all users in a group, your need to write a query to fetch these users. You know where users are (UserInfo table); now you need find information about user group assignments, join these tables together and filter by a particular group.

    If I remember AX 2009 correctly, the assignment is in UserGroupList table, and we can use code like this to test the query:

    UserInfo userInfo;
    UserGroupList userGroupList;
    
    while select Id from userInfo
    	exists join userGroupList
    	where userGroupList.UserId ==  userInfo.Id
    	   && userGroupList.GroupId == 'xyz'
    {
    	info(userInfo.Id);
    }

    It if gives you the right list of users, use the query in your previous code:

    UserInfo userInfo;
    UserGroupList userGroupList;
    
    ttsbegin;
    while select forUpdate userInfo
    	exists join userGroupList
    	where userGroupList.UserId ==  userInfo.Id
    	   && userGroupList.GroupId == 'xyz'
    {
    	userInfo.AutoLogOff = 15;
    	userInfo.update();
    }
    ttscimmit;

    By the way, please use Insert > Code (in the rich formatting view) when pasting code to this forum. You can see the result above.

  • Niresh Profile Picture
    10 on at
    RE: How to log off different user with different time in Microsoft AX?

    Hi Martin,

    Thank you very much for your guide. I will try today and let you know how I go. Thank you.

    Regards,

    Niresh Joshi

  • Niresh Profile Picture
    10 on at
    RE: How to log off different user with different time in Microsoft AX?

    Hi Martin,

    My initial testing says it works perfectly but I am waiting for confirmation for other users. My sincerely thank  you for that.

    I have one more question though as I want admin to have full time, Nurses to have 30 min and finance to have 90 min log off time. All other user will only have 5 min.

    If I add the job for nurse, finance and admin and then run the other job as per my first post to log off user, will it overwrite all jobs for nurse and other?

    To achieve my goal to log off groups in certain time and all other in 5 min time, do I have to user query for each group? Thank you.

    Regards,

    Niresh Joshi

  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: How to log off different user with different time in Microsoft AX?

    You can do it any way you like.

    If you wish, you can create a single batch job where you choose a user group and the period, and you'll schedule one job for each group.

    Or you store the configuration somewhere else and create a single batch job that'll process all user groups based on the configuration. Using a single query would make sense to me.

  • Niresh Profile Picture
    10 on at
    RE: How to log off different user with different time in Microsoft AX?

    Thank you Martin,

    If we can do the single batch job, it will be easier as we have around 10 facility. Can you please guide me how to create a single batch job? Thank you.

    Regards,

    Niresh Joshi

  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: How to log off different user with different time in Microsoft AX?

    I'm sorry, but it's not clear to what you need from us at the moment. Please elaborate.

  • Niresh Profile Picture
    10 on at
    RE: How to log off different user with different time in Microsoft AX?

    Hi Martin,

    I will like to know how to do the following:

    "Or you store the configuration somewhere else and create a single batch job that'll process all user groups based on the configuration. "

    Thank you.

    Regards,

    Niresh Joshi

  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: How to log off different user with different time in Microsoft AX?

    Data is stored in table. You can, for example, create a table with two fields - user group ID and the time period. Make the table shared across companies. When you want to set the timeout value for a user group, you'll find the record by user group ID and read the number.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 835 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans