But now I want the first and last name of the user instead. I tried a several things and I think I need something like getFirstName() or something like that. (User (Camunda BPM Javadocs 7.8.14-ee))
This function is not available out of the box like ${currentUser()}. Instead you need to make an api call to process engine services to retrieve the user object like below:
@Autowired
private IdentityService identityService;
@GetMapping(path = "/user-details" produces = MediaType.APPLICATION_JSON_VALUE)
public UserDto getUserDetails() {
User user = identityService.createUserQuery().userId(getLoggedInUserId()).singleResult();
return UserDto.fromUser(user, false);
}
private String getLoggedInUserId() {
return identityService.getCurrentAuthentication().getUserId();
}
Once UserDto is retrieved you can access the object attributes.
But now I’m struggling to set the variables for using it. Is the best way to make it with @PostMapping or is there an easier way that I don’t see? ^^