How can I assign a default user when creating a new issue so that the history log displays "<default user> created issue"
I should have stated my question more clearly. How do I programatically assign the currentUser to a predetermined user ( "defaultReporter" for example ) to really anonymize ticket creation when a logged in user creates a new issue. I am using scriptrunner and a post function/custom script in the create transition.
I can assign a default reporter, but the current user is still visable in the History or All tab of the issue. There it is documented who actually created the ticket. I need the functionallity to work for logged in users.
Thanks..
Actually I was able to resolve the issue myself with the following code..
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.security.JiraAuthenticationContext; def us = ComponentAccessor.getUserUtil().getUserByName("Anonymous").getDirectoryUser(); def ac = ComponentAccessor.getJiraAuthenticationContext(); ac.setLoggedInUser(us); issue.setReporter(us);
and it functions fine in the Create Issue transition, it is actually the first script to be called in the post functions. The assignment of LoggedInUser solved the issue of creator anonymity in the tabs History and All.
Find an add-on that can create a JIRA Issue OR will allow you to run a script that will create the JIRA issue then just use the default assignee as the reporter.
This means that the Post-function you have put will be ran after the ticket has been created. What you need to do here is to create the ticket not via the post-function. The ticket must be created outside the post-function. You cannot even put your post-function before the "Create the issue" because there's nothing to update if you put that after anything else.
That means you have a real user called Anonymous... that's not quite the same.
Actually I have to agree...went back and found the method clearLoggedInUser() in JiraAuthenticationContext which I had missed before. I have now just left the Reporter as optional and then set as hidden, in the post function I now just call ac.clearLoggedInUser() and the issue is then actually anonymous.
Thanks for the comment, got me to go back and check again...you could have just pointed out the clearLoggedInUser() method though.
I probably would have, but I thought you were happy with your solution. If you want tips, it seems like you use a try/finally block, and replace the actual logged in user. Otherwise I think this user would require to log in again.
It looks like you're new here. Sign in or register to get started.