Setting Status Bar options in Code and SQL

As a developer or functional consultant we quite often receive support requests from users with very little information as to their circumstances under which the issue occurs. E.G. What environment where they working on (Prod, QA, Dev)? What is their userId etc (in order to find out security settings applied)? What currency? and most importantly what AX company they are logged into. All of this information can be set to be displayed in the users status bar by setting enabling it per user under Administration -> Users -> Options -> Status Bar.

It really helps to have it set over there so that screenshots will normally just show this information.

However you may want to set these options globally for all users when initially configuring the system. Doing this manually is quite a tedious process and there is no field per setting to do it in a quick sql script or AX job. Rather AX stores it in a single binary field called “Userinfo.StatusLineInfo” and uses bitwise operators for setting and reading the individual options. This really makes it a bit tricky to set but is very efficient in terms of space and reading speed for the system.

So how do you perform this global setting? My first two options will show you how to set all users to have the same option sets, my last solution will show you how to set only one specific setting for all users.

OPTION 1 (AX Solution): 
1. Login with your AX user and navigate to Administration -> Users -> Options -> Status Bar.
2. Set all the status bar parameters that you would like to display for all users.
3. Create a new Job in the AOT with the following code:

static void syncAllUserToCurrentUserStatusBarOptions(Args _args)
{
    UserInfo user, updUser;
    select user where user.id == curUserId();
    
    update_recordSet updUser setting StatusLineInfo = user.StatusLineInfo;
}

OPTION 2 (SQL Solution):
1. Login with your AX user and navigate to Administration -> Users -> Options -> Status Bar.
2. Set all the status bar parameters that you would like to display for all users.
3. Login to your SQL database for AX, locate your user record in the UserInfo table
4. Copy the StatusLineInfo value field value.
5. Execute the following script

update userinfo set statuslineinfo=[COPIED VALUE]

e.g.

update userinfo set statuslineinfo=-529533

This example will set all users to have the following options: Show help text, Show Utility layer, Show Company accounts, Show currency, Show UserId, Show Alert Status, Show AOS name, Show Current Model, Show Document Attachments button, Show Record Navigation buttons, Show View Edit Record Button, Show details form details/grid view buttons.

Option 3 Set a specific option for all users:
1. Open the AOT, expand forms node, navigate to SysUserSetup Form.
2. Right click, click “View Code”
3. Open the “ClassDeclaration” method.
4. Move down to approx line 57 where there are a whole bunch of macros entitled #LOCALMACRO.FLAG_XXXXXXXX
5. Locate the macro that has the setting that you want to use e.g. #LOCALMACRO.FLAG_StatuslineShowPartition to show the default partition. Take note of the value after the “<<” symbol. E.g. 19

6. Create a new job with the following code:

static void addStatusBarOptionToAllUsers(Args _args)
{
    UserInfo updUser;
ttsBegin;
while select forUpdate updUser
{
updUser.statuslineInfo = updUser.statuslineInfo | (1 << [value from step 6]);
updUser.doUpdate();
}
ttsCommit;
}

E.G. To set all users to show default partitions:

static void addStatusBarOptionToAllUsers(Args _args)
{
    UserInfo updUser;
ttsBegin;
while select forUpdate updUser
{
updUser.statuslineInfo = updUser.statuslineInfo | (1 << 19);
updUser.doUpdate();
}
ttsCommit;
}

7. Execute the job

NOTE: To remove a setting from all users simply replace the line

updUser.statuslineInfo = updUser.statuslineInfo | (1 << 19);

with

updUser.statuslineInfo = updUser.statuslineInfo ^ (1 << 19);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s