I have a groovy postfunction in place that creates a subtask. For the most part, this works, but it fails in the case where I have a user that has had their username modified. For example, if I have a user 'jraub@company.com', but his username was initially 'jraub', my code returns 'jraub' and the validateSubTaskCreate() fails.
This problem also presents itself in my SQL reports for Confluence - when I do joins with the jiraissue table, the username related fields (assignee, reporter) always have the original 'jraub' value. Same thing with the change history related tables.
I've been reverting usernames as a workaround (only a few users affected), but I'll need to change every username on our JIRA shortly and this problem must be addressed. Can anyone offer any insight?
Thanks!
Here's a snippet of my code:
User user = ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user);
CreateValidationResult createValidationResult = issueService.validateSubTaskCreate(user, issue.getId(), issueInputParameters);
log.error("errors (1): " + createValidationResult.getErrorCollection().getErrorMessages());
for(String error : createValidationResult.getErrorCollection().getErrors().values()){
log.error(error);
}
Community moderators have prevented the ability to post new answers.
This line doesn't do anything useful AFAIK, remove it:
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user);
Replace
User user = ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser()
with
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Sorry about the delay - that solution worked.
I also solved the MySQL issue - for anyone interested, there is an "app_user" table that maps the original username to the current one for those that have been changed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Yes, that's correct. 2. user 'jraub' does not exist (or something to that effect, I'm out of office today).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> my code returns 'jraub' which bit of your code, the getDirectoryUser() ? > and the validateSubTaskCreate() fails. can you include the validation messages
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.