# How to get the current user ID?

**URL:** <https://community.ofelia.com/t/how-to-get-the-current-user-id/8221>\
**Category:** Q&A\
**Created:** [17 February 2017 06:06 UTC](https://community.ofelia.com/t/how-to-get-the-current-user-id/8221 "2017-02-17T06:06:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![januah](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@januah](https://community.ofelia.com/u/januah)\
**Post date:** [17 February 2017 06:06 UTC](https://community.ofelia.com/t/how-to-get-the-current-user-id/8221/1 "2017-02-17T06:06:09Z")

</div>

Hi,

I’m trying to get the current User ID from within the Edit Expression. Is there any API call that will return to me the user login ID from the session? I know you can do this via the UI Editor but how about within the Edit Expression?

Kindly guide me as I’m new to Bonita.

Thanks.

---

<div class="post-metadata">

**Author:** ![terry.price](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@terry.price](https://community.ofelia.com/u/terry.price)\
**Post date:** [17 February 2017 22:40 UTC](https://community.ofelia.com/t/how-to-get-the-current-user-id/8221/2 "2017-02-17T22:40:57Z")

</div>

You can find the answer to this in the getting started tutorial

Create a variable in the UI with External API, …/API/system/session/unusedId

The content expression is {{session.user\_name}}

When you create an external api variable, then there are a list of examples, so you can see the typical process related calls

---

<div class="post-metadata">

**Author:** ![Dibyajit.Roy](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@Dibyajit.Roy](https://community.ofelia.com/u/Dibyajit.Roy)\
**Post date:** [19 February 2017 13:46 UTC](https://community.ofelia.com/t/how-to-get-the-current-user-id/8221/3 "2017-02-19T13:46:41Z")

</div>

Hi

I use the Below Script to assign a task to a Specific User. This script is added to the Actor filter Section but you could use the Same inside the Edit Expression section. This script returns a User id .

I use the API …/API/system/session/ to get the username and store it inside a variable called demandReviewer .  
you could check out the identity API for more information.

import org.bonitasoft.engine.api.IdentityAPI;  
import org.bonitasoft.engine.identity.User;

IdentityAPI identity = apiAccessor.getIdentityAPI();  
User user = identity.getUserByUserName(demandReviewer);

return user.getId();

hope this helps.

---

<div class="post-metadata">

**Author:** ![januah](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@januah](https://community.ofelia.com/u/januah)\
**Post date:** [18 February 2017 01:17 UTC](https://community.ofelia.com/t/how-to-get-the-current-user-id/8221/4 "2017-02-18T01:17:11Z")

</div>

Thanks for the reply. I’m aware of that API which can be called from the UI Editor but in my case I don’t have a page because it’s a service task not a human task. I can only work within the script editor with the available classes/packages. How can I achieve the same result?
