I've created some Javascript code and I'm trying to create a Scriptrunner UI fragment. Under the "Context(s)" option, I'm unsure which one to select. I need my javascript UI fragment to run on the issue creation screen. Here's the section I'm referring to:
Hi @Midya Rahmani Welcome to Atlassian Community!
It is not possible to use Script Fragments on the Create Screen.
You can use Scriptrunner Behaviour for create issue screen.
@Ram Kumar Aravindakshan _Adaptavist_ Do you have any suggestion or workaround to add Script fragment on create issue screen ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vikrant Yadav Thanks for the reply. I tried to create a behaviour for this in Jira DC, however I ran into some issues. I wasn't able to create a behaviour for the create issue screen that could hide certain drop down values on a single select drop down custom field depending on a selected component. Do you know if this is possible with behaviours?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vikrant Yadav Thanks for your answer, I was able to figure it out using the following behaviour:
import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.onresolve.jira.groovy.user.FieldBehaviours.getFieldById
import com.atlassian.jira.component.ComponentAccessor
def componentsField = getFieldById("components")
def affectedAreaField = getFieldById("customfield_10200")
def selectedComponents = componentsField.getValue() as List<Map<String, Object>>
def isApplicationSelected = selectedComponents.any { it["name"] == "Application" }
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def affectedAreaCustomField = customFieldManager.getCustomFieldObject("customfield_10200")
def config = affectedAreaCustomField.getRelevantConfig(issueContext)
def options = optionsManager.getOptions(config)
if (isApplicationSelected) {
// Filter the options, retaining only "Administration" and "Authoring"
def allowedOptions = options.findAll {
it.value in ["Administration", "Authoring"]
}
affectedAreaField.setFieldOptions(allowedOptions)
} else {
// If "Application" is not selected, show all options
affectedAreaField.setFieldOptions(options)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Midya Rahmani 100% it's possible to hide single select list dropdown options depending on Component/s field.
Similar post : https://community.atlassian.com/t5/App-Central-questions/Show-custom-field-based-on-Component-using-Scriptrunner/qaq-p/1326648
https://gist.github.com/vikrantyadav11/bfbfb2bc0e3775def78070eece48df3b
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Atlassian Community!
The easiest way to work this out is to use the fragment finder in SR. See https://docs.adaptavist.com/sr4js/latest/features/fragments for how to find and use it
Improving the language and layout of fragments, including making the fragment finder easier to find and use is something we have in progress at the moment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your response Nic, I tried enabling the fragment locator, however it unfortunately doesn't seem to show anything for the issue creation screen:
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.