I am using script runner to auto fill the CF a value through this way:
Edit the create transition's validator:
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Project Name'} issue.setCustomFieldValue(cf, issue.projectObject.name) issue.description != null
Then if we create a issue, the CF "Project Name" will be automaticly set to the Project's name.
But we want to do this.
Add the CF "Project Name" to create screen. If the user fill this CF with a value (such as "Internal") when create issue. Then the CF value will be set to "Internal".
If the user leave this CF blank, the CF value will be set to Project's name.
How to do this?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Xinan Liu.
You probably want something like:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.Issue def cf = ComponentManager.instance.customFieldManager.getCustomFieldObjectByName("Project Name") def value = issue.getCustomFieldValue(cf); if(value == null ){ value = issue.projectObject.name issue.setCustomFieldValue(cf, value) }
Also, you should use this as a Script Post-Function rather than a validator as you are not validating the input, but rather post-processing it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't actually tested this, but if it doesn't work it should at least show you the logic to complete this. :P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks very much! It works. I know this is a Script Post-Function, but I don't konw how to set this code in Script Post-Function, I can't find the palce to write my own code. See the picture at my answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you navigate to the transition in the workflow, rather than selecting "Validators", choose the Post-Functions tab. You should see a "Add post-function" link on the right, which will allow you to choose "Script Post-Function". Then just select "Custom script post-function" and use the code you want. :)
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.