Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to set a custom field values based on request type?

DevaKiran April 19, 2019

Hi,

I am using Jira Service Desk. I have a requirement that i have a three request types and i have a one custom field which is a drop down field.

Whenever a customer need to raise a request from customer portal I need to set the custom field options based on the selected request type in customer portal.

Note: Here i am not using any Customer Request Type Custom Field.

For example:

Request Types are : A, B and C
Custom field(Type is Drop Down Custom Field) has options like a,b,c,d,e,f g,h

If i select A request type the custom field will set to a,b,c

If i select B request type the custom field will set to d,e,f

If i select C request type the custom field will set to g,h.

Is there any script  to perform this operation.

Could anyone please help me with the appropriate solution.

Thanks in Advance

6 answers

3 votes
Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2021

Hi @DevaKiran @Luvo Hubela @Steven Miller @Stephen Letch @Mariano Battaglia ,

On a Jira Service Management Server environment of a customer of mine I solved it with a Behavior (app Scriptrunner).

The script that is used in the behaviour is

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def selectList = getFieldById("customfield_12433")
def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

def optionsMap = options.findAll {
it.value in ["Option A", "Option B"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)

 

Is this an option/solution for you?

Regards, 
Marco

Adarsh Hegde January 6, 2022

Hello @Marco Brundel

Facing the same issue but in Cloud.

Thanks for the code, but this will work only on Jira DC but what's the workaround for Jira Cloud as scriptrunner doesn't yet support behaviors option.

Please suggest if possible.

Thanks,
Adarsh

Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 6, 2022

Hi @Adarsh Hegde ,

Sorry, but I don't know a solution/work around for the Cloud.

I think it would be a good idea to create a new question here on the community. Also because this question is tagged on Server.

 

greetings, Marco

Like Adarsh Hegde likes this
Consulente Atlassian February 8, 2022

@Marco Brundel 

does this script work also on the Customer Portal side?

Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 9, 2022

@Consulente Atlassian 
Yes, in my situation this behaviour works on a request type on the portal.

2 votes
Stephanie Helmeth January 15, 2020

Hi there,

I have the same challenge. The solution with configuring new contexts to the custom field does not work here as you can only define a context depending on the issue type (and project).

What we look for is a solution that sets a new context depending on the customer request type  (which is NOT the issue type) in the help desk.

Does anyone has expecrience with that?

Thanks & regards!

Milos Sretin January 21, 2020

I am facing the same issue and trying to find a solution. :(

Markus Pöhler June 12, 2020

Same here. Don't want to create additional fields. 

Very bad if you move issues from a -> b -> the fields are empty although the fields name maybe the same. Confusing stuff.

 

Thanks. 

Mariano Battaglia August 7, 2020

Someone solved it? thanks

Stephen Letch August 21, 2020

No, probably have to use an initialiser with scriptrunner if you have it. Or if you're using Insight fields, have a hidden field and make the field on the portal a reference field

1 vote
enrique_15_perez July 27, 2021

Excellent @Marco Brundel , thank you very much your comment helped me.

0 votes
Luvo Hubela April 30, 2021

Anyone have a solution to this

0 votes
Steven Miller April 16, 2021

Anyone have a solution for this? This is a pretty big deal breaker if it can't do something as simple as supplying custom fields based on request type.

0 votes
Ravi Varma
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2019

Hi @DevaKiran ,

Try configuring a new custom field context for the issue types (request types) and define the various options for each custom field context.

 

Regards,

Ravi Varma

Markus Pöhler June 12, 2020

Hi Ravi,

in the latest Version of Jira SD it is only possible to configure ONE context per project for each field. I was shocked to see this limitation because I was expecting that we can define as many different contexts for each field combined with different issue types. The configuration screen suggests this functionality, but as soon we start to configure a second context, the project that has been used iin a first confuguration is not available to select. 

This leads to a solution of the same semantic field beeing created as a custom fiel multiple times. Bad.

Any chance this could be implemented in future? Are there feature requests pending we could support?

Thanks. 

Like Johannes likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events