cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current username in javascript using script task?

madn
Champ in-the-making
Champ in-the-making
Hi everyone,

I'm trying to get the currently logged username in a script task to put it in a variable that I call in a REST call task but I don't know how to do this and i can't find any documentation on how to do this in Javascript

I don't want to use java-code (I don't know where to put the java.class files)

Thanks in advance
20 REPLIES 20

madn
Champ in-the-making
Champ in-the-making
I finally find how to solve my problem


public class myAuthTest implements JavaDelegate {
@Autowired
protected UserService userService ;
@Override
public void execute(DelegateExecution execution) throws Exception {
  User currentUser = SecurityUtils.getCurrentUserObject();
  String x = currentUser.getExternalId();
  execution.setVariable("myUserName", x);
}
}

To get the real userName

But i get another error in my process flow i expect you will go to this link to help me .

https://forums.activiti.org/content/error-java-null-pointer-exception-when-using-rest-call

Thank you all