Hello everyone,
Can you help me with a simple script in post functions section in the workflow? I hit a bug that when issues are created via email, I got in the history tab wrong user for the one who creates the issue:
"user_name created issue - date."
The problem is that this user doesn't have anything to do with the issue, no access, no nothing.
I found this and it describes exactly the issue I have: https://jira.atlassian.com/browse/JRASERVER-41322
Sadly, the discussion there ends up with "contact support" solution and that one expired for me.
So I started to search how to change the user name of the creator before the creation of the issue. Found this one:
import com.atlassian.jira.component.ComponentAccessor def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserByName("<anonymous_username>") def authContext = ComponentAccessor.getJiraAuthenticationContext() authContext.setLoggedInUser(user)
The thing is that it doesn't work, I change the user name with the desired one, preserving the :
("< >")
Nothing changes, still the created issue is from a wrong user name. The script is created in that way: post functions -> add post function -> script post-function -> inline script -> ran before "Creates the issue originally." as instructed in the thread I found.
I am running jira 6.2.7 server edition. Will appreciate any help as I am sure the stupid one here is me. :)
Best Regards,
Try to add to the end of your script:
ComponentAccessor.getIssueManager().updateIssue(userwitheditpermissions, issue, EventDispatchOption.ISSUE_UPDATED, false)
Thanks a ton for the answer.
Sadly, there is no change with the added line. The user name is still a wrong one.
The script right now:
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName("<ivelin.ognyanov>")
def authContext = ComponentAccessor.getJiraAuthenticationContext()
authContext.setLoggedInUser(user)
ComponentAccessor.getIssueManager().updateIssue(userwitheditpermissions, issue, EventDispatchOption.ISSUE_UPDATED, false)
Best Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can not see how you set value for the userwitheditpermissions variable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you explain with a little bit of a more details? I am kinda new to scripting/java/jira. The whole jira thing was transferred to me recently and I am still kinda learning, otherwise I am just a normal "dumb" windows sys admin without any experience with the above. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, try like this. If it does not work have a look at the atlassian-jira.log file for errors.
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName("ivelin.ognyanov")
def authContext = ComponentAccessor.getJiraAuthenticationContext()
authContext.setLoggedInUser(user)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.