Hello!
Having trouble setting the default form value for a custom multi-line text field when creating an issue, using scriptrunner behaviours. It works for system description field as per a scriptrunner example, but no clear way to achieve the same for a custom description field. Also total lack of information on underlyingissue class in the documentation.
def descField = getFieldById("customfield_#####")
def defaultValue = """1. Lorum Ipsum
2. random text
3. blah blah
4. Profit!
""".replaceAll(/ /, '')
if (!descField.getValue()) {
descField.setFormValue(defaultValue)
}
Tried setting it to check if the custom text field is empty, but does not work, likely not knowing for where. Hence the underlyingissue class.
It would be 'if (!underlyingIssue?.description)' for a system description field, so what would be the equivalent for a custom text field?
I tried 'if (!underlyingIssue?.getFieldById("customfield_#####"))' and ' if (!underlyingIssue?.descField)' and other variations to no avail, but spits the error that it does not exist for the class.
Appreciate any help with this, or pointing towards a better method.
Use getCustomFieldValue:
def descField = getFieldById("customfield_10084")
def descFieldObj = customFieldManager.getCustomFieldObject("customfield_10084")
def defaultValue = """1. Lorum Ipsum
2. random text
3. blah blah
4. Profit!
""".replaceAll(/ /, '')
if (!underlyingIssue?.getCustomFieldValue(descFieldObj)) {
descField.setFormValue(defaultValue)
}
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works, thank you @Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Patrick ,
i have used this code in customfield on behaviour .. where pretext is populating but its not storing any data in that field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hmm..it works for me with Jira 9.12 / latest Script Runner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.