AnsweredAssumed Answered

Getting username of the user who executed a repository tier web script

Question asked by mando.alvarado.jose on Feb 5, 2013
Latest reply on Feb 14, 2013 by mando.alvarado.jose
Title pretty much sums it up.

I need to obtain the current user's username within a repo-tier webscript's javascript code. By "current user", i mean the authenticated user that triggered the execution of said script.

I have tried to obtain this information using the now famous (to me anyway) root scope objects…namely the "person" object. According to this page:

http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FAPI-JS-rootscoped.html

…the "person" object should be available in my javascript code. It isn't clear, however, if it should be present on repository webscripts or share webscripts. In either case, whenever i try to use the "person" object, i get a 500 response with a wrapped exception message that says "ReferenceError: \"person\" is not defined.".

The javascript code responsible for this exception is trivial:

model.userName = person.properties.userName;

That's it. This isn't just the line where the error occurs…this is the WHOLE .js file.

I have been trying to resolve this issue for weeks now without any luck. The "person" object just isn't there, and for that matter, neither is "companyhome" or "userhome". I get the same error message when i try to use them.

There must be a reason why these objects aren't included/generated in my js context, but i have no idea why.

I would appreciate any help i can get on this matter. I hope i'm not the only one with this issue.

Outcomes