Hi,
I am using the script runner plugin to clone an issue to a specific project based on the value of a custom field.
By using a transition screen I can allow the user to enter new mandatory parameters required to create the issue in the new project. All statuses can transition to this status.
I can specify a transition screen in my workflow but this will mean the same screen will be shown all the time.
How can show different transition screens based on the value of my custom field? So that a new transition screen can be shown to create an issue for different projects.
You can use Behaviours to modify the visible/required fields on a screen. You can use a scripted transition to limit the behaviour to a particular workflow step, so that it's only applied on the relevant transition screen. You could add an initialization script to a behaviour with something like
if (getActionName() == "Transfer Ownership") { def fieldToHide = getFieldByName("Some custom field I wish to hide") def fieldToRequire = getFieldByName("Some custom field I wish to require") fieldToHide.setHidden(true) fieldToRequire.setRequired(true) }
Notably, that would require you to add to the workflow transition screen. If you only wanted that field to show up for that particular transition (and no other transitions), you could do something like:
def fieldsThatOnlyShowOnSomeTransition = ["Field A", "Field B", "Field C"] fieldsThatOnlyShowOnSomeTransition.each{ fieldName -> boolean includeFieldX = getActionName() == "Start Progress" def fieldX = getFieldByName(fieldName) fieldX.setHidden(includeFieldX) }
Which can be a little more readable and maintainable for a large number of fields. It's also easier to adjust if the parameters that determine whether a given field should show are more complex than simply "Are we in some particular workflow step?"
Thanks. I am currently implementing this recommendation.
I have run into one stumbling block thus far. In the Initializer function, I can get the object of one of my custom field that is of a Group Picker (Single) type using getFieldByName, but when i call getValue() on the object I get a null value.
The same function works fine if I add a field with a validation script. It seems like when the initializer script is executed the value is not yet populated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Initializer scripts are always run as soon as the page is loaded, and are only run once. If that field is empty when the page is run, you should expect its value to be null when the initializer runs.
If you need a script to run every time a particular field changes, then it needs to be associated with that field. For some cases, you may need to examine a particular field in both an initializer and in a validation script on that field (or even on some other field). It just depends on what you're trying to do with that script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's not quite the case... no values are available in an initialiser whether set or not. You can get the value of any CF using the regular java api, getUnderlyingIssue() will give you the regular Issue object, then use issue.getCustomFieldValue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could anyone please confirm if this method works still and send a copy of their script. Mine is not working for workflow function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
I am trying to achieve same thing. I would like get a transition screen when I move my user story from Status A (backlog) to Status B (sprint backlog.)
Transition Screen needs user input to move to status from Status A to Status B.
Any suggestions would be really helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could create several transitions with different transition screen.
Add a condition on each to show for user only one at a time basedon custom field value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have over 20 statuses in this workflow with each status allowing all transitions from any other status enabled.
If we had to keep the same behaviour by creating individual transitions between each status, that would make the workflow really cluttered and messy.
Is there no other alternative ? Like calling a ShowScreen("ABC: Bug Screen") method from a condition ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the problem I am trying to solve:
We have a project A that contains issues that Team A works on. Team A assigns these issues to various other teams using a custom field group picker, example team B.
Team B does not want to conform to project A's workflow and custom fields. They want to use their own workflow and custom fields.
To solve this we are using the script runner clone issue post-function. We check the value of the custom field and depending on the value we create the linked issue to the new project, example project B that team B works on. Project B requires additional information when creating issues, Team A knows this information, so they need to fill these in when assigning the ticket to Team B.
Depending on the team that Team A assigns the issues to, the issues will need to be created on a new project showing different screens.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good day,
I'm using the same code and nothing is happening
Below is my code and it's not doing anything.
import com.onresolve.jira.groovy.user.FormField
FormField dropDown = getFieldById("customfield_10306")
FormField fconditionA = getFieldById("customfield_10510")
FormField conditionB = getFieldById("customfield_10515")
if (dropDownValue.getFormValue() == "High")
{
conditionA.setHidden(false)
conditionB.setHidden(true)
}
else
{
f conditionA.setHidden(true)
conditionB.setHidden(false)
}
Jira Service Desk 3.6.1
ScriptRunner 5.1.6
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.onresolve.jira.groovy.user.FormField
FormField dropDown = getFieldById("customfield_10306")
FormField fconditionA = getFieldById("customfield_10510")
FormField conditionB = getFieldById("customfield_10515")
if (dropDownValue.getFormValue() == "High")
{ //Yes
conditionA.setHidden(false)
conditionB.setHidden(true)
}
else
{
f conditionA.setHidden(true)
conditionB.setHidden(false)
}
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.