Version
Jira v8.4.2, Scriptrunner 6.0.2-p5
What I want to do
In our project we have a set of issuetypes which can be both task or subtask, sharing the same screens when doing create/edit/view. If the issutype = subtask then we do not want to show some 'change management' fields. All field names starts with 'CM'. To avoid the need to update the script if adding yet another CM-field, I have tried to figure out if I can but I could not find any getFields... - only getField...
But maybe there is a reason?
While preparing the question I realize that it might be a very good reason for this not being a clever thing to so - could it have major impact on performance if needed to loop all fields every time an issue is being rendered?
This may be of use to you: https://docs.atlassian.com/software/jira/docs/api/7.2.0/com/atlassian/jira/issue/CustomFieldManager.html#getCustomFieldObjects-java.lang.Long-java.lang.String-
Here's a sample implementation:
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
List<CustomField> fields = customFieldManager.getCustomFieldObjects(10800,"Request")
fields.each{field ->
if(field.fieldName[0..1] == "CM"){
//Do Stuff
}
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.