I want currently logged in camunda userid and firstname this is for start form once its submitted it will go for approval I want current logged in approval userid and name.
@Amar You can use identity service to get the logged in user details.
@Autowired
private IdentityService identityService;
public String getLoggedInUserId() {
return identityService.getCurrentAuthentication().getUserId();
}
public UserDto getLoggedInUserDetails() {
User user = identityService.createUserQuery().userId(getLoggedInUserId()).singleResult();
log.info("Logged in userid: {}, first name: {}", user.getId(), user.getFirstName());
return UserDto.fromUser(user, false); //UserCredentials will be ignored if set to false
}
Hi @Amar,
I assume that you are using html embedded forms.
Please have a look at below post.
Use data.firstName
to get the first name
Hi Hassang, I’m using generated forms
can you please share me with import statements
import org.camunda.bpm.engine.*;
import org.camunda.bpm.engine.identity.*;
import org.camunda.bpm.engine.rest.dto.identity.*;
import org.camunda.bpm.engine.task.*;