We are currently experiencing intermittent login issues on Community.  The team is actively working on a fix.

shruti_tyagi
ServiceNow Employee
ServiceNow Employee

User ID is a Unique identifier for the user's ServiceNow login user name. The maximum length of the User Id field in the User table is 40, which means the User Id in the User table can only have 40 or fewer characters.

find_real_file.png

- If you will try to manually create a user with a User id longer than 40 chars, the system will not allow you to create it. 

- If users are created from the integration and have User id longer than 40 chars. The user Id will be truncated to 40 characters.

You may have a requirement to allow User Id with more than 40 characters, due to the reasons like users imported from integration have User Id as Email or Domain. In this case, the system allows you to increase the length of the User Id to the large value.


But wait before updating the max length of the User Id field, here is something you should know.

 

What else is dependent on User Id Field?

Created by and Updated by fields populate the User Id of the User. The maximum length of Created by and Updated by is also 40 characters. These are the Read-Only Out of Box fields that are created with every table.

If you increase the length of the User Id field, that will be incompatible with created by and updated by field.

What are the issues users with longer User Id’s will see?

If you have users with user id longer than 40 characters, the user id is created by and updated by field will be truncated to 40 chars and the user can see multiple issues, such as:

• When users have a user_name longer than 40 characters they cannot download lists exported to Excel. When attempting to download, they are taken to a blank sys_attachment page.

• Users are unable to attach attachments from the service portal or normal UI to any record. After attaching the file and upload No attachments are added and not shown on the form.

• User will notice their name is truncated to 40 chars on activity stream for any record.

 

How can you identify if you have users that can have this issue?

Here is the script admin can run from script background, to see the number of users impacted:

 

(function() {
    var dict = new GlideRecord('sys_dictionary');
    dict.addQuery("name", "sys_user");
    dict.addQuery("element", "user_name");
    dict.addQuery("max_length", ">", "40");
    dict.query();
    while (dict.next()) {
        var usernamelen = dict.max_length.getValue();
        gs.print("UserNameMaxLength : " + usernamelen);
        var noofusers = 0;
        var countuser = new GlideAggregate("sys_user");
        countuser.addActiveQuery();
        countuser.addAggregate('COUNT');
        countuser.query();
        if (countuser.next()) {
            noofusers = countuser.getAggregate('COUNT');
            gs.print("TotalNumberOfUsers : " + noofusers);
        }

        var user = new GlideRecord('sys_user');
        user.addActiveQuery();
        user.query();
        var count = 0;
        while (user.next()) {

            var userId = user.user_name.toString();
            userId = userId.length;
            if (userId > 40) {
                count++;

            }
        }
        gs.print("UsersWithLongNames : " + count);
    }

})();
2 Comments