PostFunction currentUser

Francisco Trindade August 10, 2016

I have the following line of code

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();

Then I proceed to call

(comment != "") && commentManager.create(parent, currentUser, comment, true);

My question is, that `CommentManager` now requires the `applicationUser` object instead of a `String`. So how do I get the `currentUser` that would return the `applicationUser`.

 

 

1 answer

1 accepted

1 vote
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2016

Once you get the currentUser then you can import UserManager and use

getUser(String userName) to get ApplicationUser and pass it to CommentManager

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2016

For newer JIRA version you can try - 

getUserByName(userName) in UserManager instead of getUser(userName)

Francisco Trindade August 10, 2016

So something like,

ComponentAccessor.UserManager.getUserByName(currentUser) ?

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2016

ComponentAccessor.getUserManager().getUserByName(currentUser)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events