getUsernameFromID is not a function


Hi there!
I am trying to execute this method but it says it’s not a function. Although, I can execute other methods in the Users namespace.

function onUpdate(){
    print("running onUpdate");

    var identifiers = AvatarList.getAvatarIdentifiers();

    for (var iPos = 0; iPos < identifiers.length; ++iPos) {
        var sessionID = identifiers[iPos];
        print("sessionID: " + sessionID);

        var userName = Users.getUsernameFromID(sessionID);    // *** gets ERROR *** //
        print("userName: " + userName);

    var kick = Users.getCanKick();    // *** this WORKS *** //
    print("kick: " + kick);

Here is my script:
Any ideas?

Here’s my script:


Hi. Use Users.requestUsernameFromID instead of Users.getUsernameFromID.

There’s a typo in the API docs; I’ll submit a fix for it.

Note also, that the function has no return value, i.e., it doesn’t return the user name directly. Instead, connect to the signal, Users.usernameFromIDReply - this will be triggered when the user name has been retrieved from the server.


Thanks! I was certain is was a spelling error :stuck_out_tongue:


You may find the script, currentAPI.js, useful. It lists pretty much the whole API available (some isn’t in the docs yet). To run it, search for it in the Running Scripts dialog.


I tried running it as a server script and it says:

[UncaughtException (construct {763fbc38-f3bb-4736-973f-d9689738ea49})] Error: Can’t find variable: Users in
() at
() at -1

Any ideas?

Here’s the script:


The script appears to be working without error for me, now. Though you may have updated it since your last post.


It works when running as a SCRIPT URL. But when running as a SERVER SCRIPT URL is gets that error.

These are the errors in the Server Log:

[05/14 15:36:29] [DEBUG] [hifi.scriptengine] [1738] [entity-script-server] Done downloading script at: “

[05/14 15:36:29] [WARNING] [default] [1738] [entity-script-server] Setting::Interface::init() for key “com.highfidelity.experimental.enableExtendedJSExceptions” - Manager not yet created. Settings persistence disabled.

[05/14 15:36:29] [WARNING] [default] [1738] [entity-script-server] Setting::Interface::init() for key “com.highfidelity.experimental.enableExtendedJSExceptions” - Manager not yet created. Settings persistence disabled.

[05/14 15:36:29] [CRITICAL] [hifi.scriptengine] [1738] [entity-script-server] [about:Entities 1] [UncaughtException (construct {763fbc38-f3bb-4736-973f-d9689738ea49})] Error: Can’t find variable: Users in
[05/14 15:36:29] [CRITICAL] [hifi.scriptengine] [1738] [entity-script-server] [Backtrace]
[05/14 15:36:29] [CRITICAL] [hifi.scriptengine] [1738] [entity-script-server] () at
[05/14 15:36:29] [CRITICAL] [hifi.scriptengine] [1738] [entity-script-server] () at -1


@Spinteractive You’re trying to run the script as a server entity script, by using an entity and setting that entity’s “Server Script URL”? … Yes, that won’t work because the “Users” API isn’t available for server entity scripts. That API is only available for Interface scripts, client entity scripts, and assignment client scripts. See the “available in” table at the top of the docs page,

I suspect you don’t want to run it as an Interface script or a client entity script, in which case you’d run it as an assignment client script by adding an entry in the “Scripts” section of the server’s settings page.


Yes that’s what I want to do. Thanks for clarifying :slight_smile: