Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Make field optional ONLY on create issue screen

Deleted user
October 9, 2018

Hello everyone

I have a custom field and set it to required via field configuration for this specific issue type.

The only time it should be optional is when the issue is being created since the value cannot be set at this time.

At the moment, I have the following initialiser in my behaviour.

//Set Summary

String year = new Date().format('yyyy')

def Summary = getFieldById("summary")

if(Summary.getValue() == null)
{
Summary.setFormValue("Zinsnachzahlung " + year)
}

//Make PK-Support optional on create issue screen
if (getActionName() in ["Create Issue", "Create"])
{
def PKS = getFieldById("customfield_11904")

PKS.setRequired(false)

PKS.setReadOnly(true)
}


What this looks like.

 image.png

After clicking on create however.

image.png
Any idea on how else I could achieve this?

Thanks and best regards

Marius

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Daniel Garcia
Contributor
February 2, 2020

I wonder if we could workaround the issue by having a custom scripted field that just returns the value of the database picker. We could then search on that.

Hayden Smith
February 21, 2020

Thanks for the suggestion Daniel.  It's taken a while for me to have a chance to look at it but I can confirm that using the resource to take the id value stored by my database picker field and then pull the friendly name from the resource I can store the values in a scripted field and search on that.

It's clunky but the main thing is that it works.

Rodolfo So
September 24, 2020

can you share how do you execute that? Thanks

Daniel Garcia
Contributor
September 29, 2020

The scriptrunner for jira plugin lets you define derived fields that are defined with a groovy script

TAGS
AUG Leaders

Atlassian Community Events