Hello,
We have ScriptRunner and Jira Misc Custom Fields plugins installed on our JIRA Server.
I want to be able to set a scripted field value based on either a JQL query, or preferably a range of non-overlapping saved filters.
For example:
If issue appears in Filter 1 - Set to "Placeholder"
If issue appears in Filter 2 - Set field status to "To Do"
If issue appears in Filter 3 - Set field status to "In Progress"
If issue appears in Filter 4 - Set field status to "Done"
Anyone know if this is possible, or be able to provide an example scripted field script that I can implement?
Thanks!
Matt
For running JQL in scriptrunner, have a look at https://library.adaptavist.com/entity/perform-a-jql-search-in-scriptrunner-for-jira
However, when you're working with a scripted field on an issue, there's no huge reason to run JQL - it's for searching for issues, and when you already have the issue, you don't need to search for it. I suspect your scripted field probably should be more simple - a series of "if" statements that return one of your four status values.
Thanks - I'll take a look at that link.
A series of statements probably is a better solution, although I'm not an expert at creating scripted fields (yet), so thought using a JQL filter might be more helpful, as I can tweak it more easily if I need to make a change.
Is there any useful mapping resource that you're aware of for JQL to scrips? e.g. I would need to learn how to search for something like this "sprint not in futureSprints() or (sprint in futureSprints() and status = done")" in a scripted field?
Are there any specific reasons to avoid using JQL in a scripted field? e.g. is it performance heavy?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can write messy and slow JQL, but there's no reason not to use JQL in a scripted field if you need to. You can build queries in code by adding clauses together, or just feeding it a valid filter string.
The reason I'm questioning this is that I can't think of a good use for a scripted field that searches for "sprint in futuresprints and status = done" - what do you want that scripted field to do with the list that relates to the current issue?
There are other searches which make more sense - "add up a number field on all the subtasks of this issue", but for ones like that you can get a list of subtasks faster and in less code with the line
def list-of-issues = issue.getSubTasks()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️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.