Hello,
I have this script but I want to customize it as per the requirement below-
I want that if my issue (for example ABC-103 is having the issue rank- 5) is moved/transitioned to production then the issue (whichever it is with issue rank -6 ) should change its value from 6 to 5.
similarly, if an issue ABC-110 (any random issue) moves to production with an issue rank say -10 the issue with issue rank -11 must change its issue rank to 10.
import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.ModifiedValue; String String = "Select List"; DefaultIssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); CustomFieldManager CustomFieldManager = ComponentAccessor.getCustomFieldManager(); CustomField cf = CustomFieldManager.getCustomFieldObjectByName(String); def availableOptions = ComponentAccessor.optionsManager.getOptions(cf.getRelevantConfig(issue)) // find the custom field option valuedef currValue = availableOptions.find { it == issue.getCustomFieldValue(cf) } // convert the option value to a long data typedef optionValue = Long.valueOf(currValue.toString()) // decrement the valueLong newValue = optionValue-1; // find the option value that match the decrement valuedef optionToSet = availableOptions.find { it.toString() == newValue.toString() } // update the new option if foundif(optionToSet) { cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf),optionToSet), changeHolder); }
Hi @Priyanka khare just trying to get more information. So the use case is, you have list of tasks (sorted by issue rank)
When ABC-1 goes to production, list is changed to
Is it correct?
Hello, @Martin Bayer _MoroSystems_ s_r_o__ , yes I am trying to achieve exactly that.
Let me know if you have any solution.
Thanks in advance.
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Priyanka khare , are you working with Jira API? I do not have solution for this exact problem. It is not so complicated so I will just try to describe what is the necessary to do (with short code snippets) and you can ask for more help if you can't make it, ok? :)
jqlSearch = '"Select list" is not EMPTY'
parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.elog("Invalid JQL: " + jqlSearch)
return (1)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello @Martin Bayer _MoroSystems_ s_r_o__ ,
Thank you so much for the code snippet,
Do u think the script below is going in the right direction in anyway-
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.ModifiedValue;
SearchService.ParseResult parseQuery(ApplicationUser searcher,
String query)
jqlSearch = '" Project Ranking" is not EMPTY'
parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.elog("Invalid JQL: " + jqlSearch)
return (1)
}
I am new to scriptrunner and groovy and would like to seek your help in-
can u provide me any referenced document for the points you have suggested here? I tried to find the code snippets for the same but did not find any,
any help would be highly appreciated.
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Priyanka khare , I'm really sorry but unfortunatelly I do not have enough time to write the whole script.
You can get a lot of resources on following web pages:
I hope, you will find out this resources usefull. Get back to this thread when you have something at least partially working. We can fix small mistakes/bugs together.
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.