I am working on a service desk feature request that needs to automatically route certain request types.
Now, In order to allow for the service desk agents to manage business rules via JIRA, I am thinking of using a multiline custom field and set its default value to a CSV value that I should be able to retrieve using ScriptRunner. Since I am using this field mainly to store static data, it is not being used on any issue screens nor will it be ever shared on the screen. The only thing I have to play with is the custom field ID.
My problem is that I am not able to find any information on "how to retrieve a custom field's default value when there is no issue attached to it" So looking for some help to point me in the right direction to be able to do something like this, if it is possible?
Thanks
Hey Anupam,
So you can have multiple configurations for a custom field. Now lets say that you want the default value for the custom field, wtihin the global context. In that case you can use
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("FreeTextA")
def fieldConfig = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(IssueContext.GLOBAL, cf)
def defaultValue = cf.getCustomFieldType().getDefaultValue(fieldConfig)
Now lets say that you have a different defalut value for the same custom field for a specific issue type (let's say Task), then in the above script the fieldConfig will be
def issueTypeId = ComponentAccessor.constantsManager.allIssueTypeObjects.find {it.name == "Task"}.id
def fieldConfig = new IssueContextImpl(null, issueTypeId)
Hope that makes sense ...
Kind regards, Thanos
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.