# Get current CMS user on Groovy updater scripts

**URL:** <https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [May 12, 2022, 12:57pm UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195 "2022-05-12T12:57:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Razvan](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/razvan/32/2111_2.png) [@Razvan](https://community.bloomreach.com/u/Razvan)\
**Post date:** [May 12, 2022, 12:57pm UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195/1 "2022-05-12T12:57:23Z")

</div>

Hello,

I am using the version 12.6.25 off Bloomreach Experience Manager.

Each time I do an update on a document using an Groovy updater script I want to update the value of the field hippostdpubwf:lastModifiedBy with the user name that is currently logged into the CMS and executes the script.

If I retrieve the value of the user from the session with the bellow example, it always returns the values **system** , with any user that is logged into the CMS:  
`node.getSession().getUserID()`

Is there any way to retrieve the value of the actual user that connect to the CMS (not system) on the Groovy updater scripts?

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [May 15, 2022, 3:28pm UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195/2 "2022-05-15T15:28:11Z")

</div>

Right off the top of my head I don’t think so. The updater runs in a somewhat protected environment. You could consider adding the user as an unput parameter, but that would be manual input which is error prone. I won’t say with certainty that it isn’t possible, but I can’t immediately think of a way.

---

<div class="post-metadata">

**Author:** ![jeroen.hoffman](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jeroen.hoffman/32/43_2.png) [@jeroen.hoffman](https://community.bloomreach.com/u/jeroen.hoffman)\
**Post date:** [May 16, 2022, 7:33am UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195/3 "2022-05-16T07:33:10Z")

</div>

You can try static `org.hippoecm.frontend.session.UserSession.get().getJcrSession()`, but not completely sure if the static #get() returns something in Groovy.

---

<div class="post-metadata">

**Author:** ![Razvan](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/razvan/32/2111_2.png) [@Razvan](https://community.bloomreach.com/u/Razvan)\
**Post date:** [May 16, 2022, 3:59pm UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195/4 "2022-05-16T15:59:48Z")

</div>

> [@jeroen.hoffman](#):
>
> org.hippoecm.frontend.session.UserSession.get().getJcrSession()

@jeroen.hoffman I’ve tried your approach but it does not work on the editor scripts. When I try to retrieve the user with _org.hippoecm.frontend.session.UserSession.get().getJcrSession()_ I get the bellow error:

_org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-5-thread-1_

---

<div class="post-metadata">

**Author:** ![machak](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/machak/32/1298_2.png) [@machak](https://community.bloomreach.com/u/machak)\
**Post date:** [May 16, 2022, 9:22pm UTC](https://community.bloomreach.com/t/get-current-cms-user-on-groovy-updater-scripts/3195/5 "2022-05-16T21:22:40Z")

</div>

UserSession.get().getJcrSession() uses threadlocals I believe and is tied to user request. Groovy scripts are run as a background task and run by “system” user  
(in most cases are not even triggered by a user, but scheduled or bootstrapped into registry).
