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);
}