It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

create multiple form for a particular Request types Edited

How can I generate custom sub fields based on  the previous field selected in the request form based on dropdown selection

2 answers

0 votes
Bryan Bojorque Community Leader Dec 23, 2019

You probably have the same issue with this guy here.

https://community.atlassian.com/t5/New-to-JSD-questions/Restrict-custom-field-values-in-Request-Type-groups-in-customer/qaq-p/1256260#M444

I did a bit of tinkering myself and the problem is I can't get the Customer Request Type in the create screen. 

The workaround is to detect the issuetype and then based on that the dropdown will change.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def issueField = getFieldByName("Server")


// Get the current issue type
def issue = getIssueContext()

// Get the current user
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def customField = customFieldManager.getCustomFieldObject(issueField.fieldId)
def config = customField.getRelevantConfig(getIssueContext())

def options = [:]
def listOpt = []

if(issue.getIssueType().name == 'Service Request'){ // IssueTypes inside Confluence Group
listOpt = ["Server 1", "Server 2"]
}else if (issue.getIssueType().name == 'IT Help'){ //IssueTypes inside Jira Group
listOpt = ["Server 3", "Server 4"]
}

options = optionsManager.getOptions(config).findAll{ it.value in listOpt }
issueField.setFieldOptions(options)

We use the Dynamic Forms add-on heavily for this type of thing. The add-on is solid with excellent support. The pricing got a little heavy handed for Jira Data Center customers with the new model but there is not much we can do about that. Still reasonable price for server customers. Not sure what you are running but this add-on provides a lot of rich features for dynamic fields and dynamic tabs. 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you