Hi,
tl;dr
if I fill a field in the first post function of a transition, and then create a subtask in a second post function of that same transition, the value of the field is not copied into the subtask. How can I force this?
Full explanation:
I'm trying to prevent people from reviewing their own work in Jira. I'm not talking about code-reviews or something like that, but a procedural check by someone else to see that we have not forgotten anything and that all systems are running correctly before releasing it to our customers. As we work with large teams / departments in a single project in Jira, the pool of potential review candidates is large and varies often.
The workflow is pretty straight forward:
Between step 2 and 3, a variable number of subtasks is automatically created depending on what needs to happen (e.g. Design, Documentation, Implementation, Test and Review).
To prevent people from reviewing their own work I've added a couple of post functions in the transition between 2 and 3. First off, I use a simple script to populate a custom user picker field 'Current user' with the account of the person that has clicked the transition. Second, I create a subtask 'Review' where I copy all fields in. To prevent the self-review, I make sure that the transition in the review subtask cannot be performed if the user equals the value of the custom field.
Main ticket:
Sub-task:
The issue then is that despite the first post function working well (the 'Current user' field is filled with the correct information), the field remains empty in the subtask.
I tried to add a third post function that explicitly copies the value from main task into the subtask, but to no avail.
When I split the two actions (fill the field 'Current user' one transition before, and then create a subtask in the next transition), everything works exactly like it's supposed to, but I would hate to add a status just to fix this problem.
Is there a way to get this all done in a single transition?
Try moving the update post function right after the first one. I use a post function to set the date in a custom field but that only works if the update function is before I set the date. Otherwise the date is set to the last time the issue was updated.
Edit: scratch that! The update any field from JSU allows me to set the value with %%CURREN_TUSER%% and that works.
So solution accepted!
P.s. still very strange that this works, but the script that essentially does the exact same thing doesnt.
Not sure I follow. The standard 'Update Issue Field' post-function does not allow for custom fields to be updated. The 'Update Any Issue Field (JSU)' from the JSU addon, does not allow for a script to be inserted. ScriptRunner has no update field post-function other than what I'm already using.
The script btw is:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.MutableIssuedef Issue = issue as MutableIssuedef loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef customFieldManager = ComponentAccessor.customFieldManagerdef assignee = issue.assignee
def currentUser = customFieldManager.getCustomFieldObjectsByName("Current user")[0]issue.setCustomFieldValue(currentUser, loggedInUser)
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.