Hi Community, is it possible to hide certain values/options in Priority Field (System Field) on Customer Portal based on Issue Type (Incident)
I am using this code in Behavior using Scriptrunner, and I know I might doing it wrong, can you help me out of it? Thanks!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
// Get the current issue type from the issue context incase the issue
// has not been created yet
def issuetype = underlyingIssue?.getIssueType().name
// Get a pointer to my select field
def selectcf = getFieldByName("Priority")
// Get pointers to the required custom field and otion managers
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(selectcf.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
// If issue type matches change the cf values to be displayed
if (issuetype.contains("Incident")) {
def optionsMap = options.findAll {
it.value in ["A", "B"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf.setFieldOptions(optionsMap)
}
Hi Alvin
Check this bit of code out. This would get all of the priorities with less than "2". Priorities are ordered by id.
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
def constantsManager = ComponentAccessor.getConstantsManager()
def allowedPriorities = constantsManager.getPriorityObjects().findAll {
it.id.toInteger() < 2
}.collectEntries {
[(it.id): it.name]
}
getFieldById(PRIORITY).setFieldOptions(allowedPriorities)
Do say if I can help you further.
Cheers
DY
Hi @Daniel Yelamos [Adaptavist] , Thank you for a very quick turn-around. I've already made a new question, Kindly check it via this link if you have time. Thanks
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.