It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I anonymize issue creation in post function via scriptrunner

Mark Butterfield Jul 13, 2016

How can I assign a default user when creating a new issue so that the history log displays "<default user> created issue"

  1. 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..

2 answers

1 accepted

0 votes
Answer accepted
Mark Butterfield Jul 15, 2016

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.

JamieA Jul 19, 2016

That means you have a real user called Anonymous... that's not quite the same.

mark butterfield Jul 20, 2016

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.

JamieA Jul 20, 2016

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.

Mark Butterfield Jul 20, 2016

Actually the user remains logged in. Also even if I am happy with the solution..I am even happier to find a more correct solution or other options. Also it is helpful for others searching for solutions if an expert points out short-commings or suggests other solutions..so Please comment when you can! Thanks again!

0 votes

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.

Mark Butterfield Jul 14, 2016

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..

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.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

775 views 7 0
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you