We are using Script Runner to create sub-tasks on transition. How do we set up the post-function so that sub-tasks are only created for specific projects, and not for every project?
Example:
Project A transitions a Story to "accepted" and 3 sub-tasks are auto created
Project B transitions a Story to "accepted" and no sub-tasks are created
You could use different scripts by having different workflows, or you could stick an "if" statement into the script to check which project you are currently in.
Nic, I would like to add an "if" statement but can not find the syntax for getting the project name and/or id. The post function is run against the Accepted transition - issue.status.name == 'Accepted'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a similar condition using the built-in script for creating subtasks on the Create transition, it's: issue.issueTypeObject.name == 'Story' && issue.getProjectObject().getKey() != ‘Project B' So, here, if it's a story and not Project B, the sub-task is created. I have two of these post functions defined, one per sub-task.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jeremy, What do you mean by you have two of these post functions defined, one per sub-task? We are not having any luck using the script you gave us. Having no issues using issue.status.name script and sub-task are created, but need the ability to make sure it's only for projects that we have in the script, since there will be projects on the workflow that will not use this function. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I mean my workflow's "Create" transition has two "Post Functions", both of which are of type "Script workflow function : Create a sub-task". Each of them has the criteria I listed above, replacing "Project B" with the one project I don't create sub-tasks for. For you, you'd need 3 post functions, unless you are creating them in a single custom script; at that point, my example condition will need to be integrated into your script as an explicit "if" statement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Jeremy! This worked perfectly - issue.issueTypeObject.name == 'Story' && issue.getProjectObject().getKey() != ‘Project B'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jeremy, What if we had two or more projects that would be running the same script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, it depends on if you want to create subtasks for them or not. Say you have 4 projects, and you want subtasks for 3 out of 4, you use the same condition as above, where it's: issue.issueTypeObject.name == 'Story' && issue.getProjectObject().getKey() != ‘Project 4' If you only want subtasks for project 2, it's: issue.issueTypeObject.name == 'Story' && issue.getProjectObject().getKey() == ‘Project 2' And if you want subtasks for 1 and 4, you could use either: issue.issueTypeObject.name == 'Story' && issue.getProjectObject().getKey() != ‘Project 2' && issue.getProjectObject().getKey() != ‘Project 3' or: issue.issueTypeObject.name == 'Story' && (issue.getProjectObject().getKey() == ‘Project 1' || issue.getProjectObject().getKey() != ‘Project 4')
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.