Hi dear community,
I have a very simple request from a user, as it seems to me, but unfortunately with my very very basic coding know-how I cannot do the script. Please help me.
This is what my user wants:
If a certain custom field (namely "production relevant") is NOT checked, the priority should be set to "normal". Else set the priority to "high".
The custom field id of the production relevant is 12900.
Thanks in advance!
Best, Anna
https://library.adaptavist.com/entity/update-priority-based-on-a-custom-field is mostly what you need here.
Hi Nic,
thanks I looked at the script. I am sure, as an expert, you can you some parts of the script. Even though I am not one, just a beginner - in fact - I tried to modify the script but it still brings errors.
Can you help me further?
Thanks in advance!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
final customFieldName = "Production Relevant"
//Get custom field issue with this name
def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
def customFieldVal = issue.getCustomFieldValue(customField) as LazyLoadedOption
//Create priorities
def priorities = ComponentAccessor.getComponent(PriorityManager).priorities
def highestPriority = priorities.findByName("High")
def normalPriority = priorities.findByName("Normal")
//Assign priority depending on the custom field value
if (customFieldVal?.value == true) {
issue.setPriorityId(highestPriority.id)
}
else {
issue.setPriorityId(normalPriority.id)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A post-function script won't work in a Behaviour initialiser, they are for doing totally different things.
Try your script as a post-function, those are for setting field values based on other data.
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.