You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
We have a scriptrunner Job, that runs daily. The purpose of the job is to fetch some information from the db & update the issue as a cascading drop down. I want to change this field to a single drop down. Can I please get help with making the value to be inserted as a single drop down.
Hello Aisha @AisM :)
Of course, I'll be glad to help. So, I think you have a cascaded field but you want to change it to a single drop-down and you want to change the scriptrunner code accordingly.
Please share the code which will be a good start to update. I will check the code and help you change the relevant part.
Best
Hi @Tuncay Senturk ,Yes! thank you sooo much :)
To give some info : The field values are being fetched into the jira database from another team’s database. In Jira the value is spit into a parent and child drop down and updated for the issue. Now we are planning on using a new custom field in Jira with a single drop down.
Example - In db table ,field value is stored as Option1,Option2
In Jira it’s split and updated as Option1 (Parent value) & Option2 (Child value) by the script job.
Below is a snippet of the old code (where the splitting happens) that populates the value into the cascading field for the Jira Epic issue type ONLY if it’s empty :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
Thanks for providing the details. @Nic Brough -Adaptavist- already provided how to update a regular drop-down using Script Runner.
As far as I understand, you will use parentOption (which is Option 1 in your DB) to update the drop-down and you will remove those childOption parts from the code.
Do you want me to help you code the related part?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk @Yes pleaseee :) that would be so so helpful
Actually going forward, there will no Option1,Option2 . . Just one value without the comma (,) on the database tables
Example:
Option blah A
Option blah B
Option blah C
So, for Epics will EMPTY values, this will get updated with the values from the db . Hope I made sense.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok sure! Please give me some time. I will work on the code after business hours :)
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.
Hello @AisM
Sorry for the delay, I just had the time.
Below is the updated code relevant to the one you already shared.
Assuming,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
String strEIT = "value-from-db"
String strEC = "ABC-123"
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(strEC)
if (issue && issue.getIssueType().getName().equalsIgnoreCase("epic")) {
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12898)
def availableOptions = ComponentAccessor.optionsManager.getOptions(customField.getRelevantConfig(issue))
def optionToSet = availableOptions.find { it.toString() == strEIT }
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), optionToSet), new DefaultIssueChangeHolder())
}
I hope it helps, please let me know if you have further questions.
Tuncay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
Have you had a chance to use the code above?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk , Thank you a million much for the script . . !!! Got sidetracked with some personal work, so was away from work . .
I’m actually waiting on my access the DB to actually have a view at the data :). But let me just try this out for a single project and see if it works . .
Also,
String strEIT = "value-from-db"
String strEC = "ABC-123"
Should I change anything here before I try it in my instance ?
Thank you so much for taking time to help ! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
Those variable names come from the ones in your code. Getting the value from DB part was not in the code, so I had to remain it as below
String strEIT = "value-from-db"
value-from-db should be the value coming from the DB.
below is the issue key, of course, it needs to be updated accordingly. Again, strEC was holding the issue key in your code, but the related part did not exist. So I just put it there as below:
String strEC = "ABC-123"
Hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk Thank you for the explanation :)
Also, due to some management confusion at my org I’m unable to get access to the db and test this scenario . .
So, I’ll accept your answer for now, as I’m sure it’ll work :) And thank you once again for being a life saver :):):)
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.
Here;s how to work with single-select lists: https://library.adaptavist.com/entity/update-a-single-select-drop-down-custom-field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk !! Hope your are well :) This is me Aisha, I am having some problem accessing my original account. So, using this account for the time being :)
So, I have been looking for some way to update my existing script. Can you pleaseeee have a look & let me know what you think. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk , Just wanted to ask a random doubt . . Didn’t find anything online while searching . . :)
Our workflow post functions have the resolution of the issue will be set to -1 . . What does that mean ? Also, what happens if i set it to None . .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
I don't know what "-1" value means but it may probably be the code that your Jira admins set.
The Resolution field is a very important field in Jira. If it is set to a value (no matter what), it means that the issue is closed. Resolution value specifies the reason an issue is closed. In Jira reports, this field is used for the Closed/Resolved tickets.
So, if you set its value to None, it means that the issue is still not closed and needs working on it.
I hope it makes sense.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk Thank youuu !
Oh okay, makes sense . . We aren’t sure how it got set to -1 . .
So, what happens if the resolution is not set for a particular status, like for example - FEEDBACK . . So, does that affect the reporting in any way, or is it always necessary to set a resolution value in the workflow post function for every status
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Resolution is a Jira system field just like the Status. It does not provide values per status. An issue can have only one resolution value and by default, it is not set, null value.
If you set any value to an issue, it means that the issue is resolved. Generally, this field is set by the latest status in your workflow (e.g. RESOLVED, CLOSED, DONE, etc) and it should be cleared (set to none) if you reopen the issue.
I hope it was clear.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk , Hope you are well !! :):) Lol, its been so longgg since I came to the community page . . . Was on a long break from Jira :D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @AisM
Welcome back! I am all good, hoping the same is true for you. Waiting for your questions then :)
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.