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

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
1 vote
Answer accepted
Edwin Ruiz October 24, 2018

How about changing the custom field to optional in the field configuration for the project and keeping the code you have for the behaviour and adding a else: 

//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)
}else{
// will go here on any other screen that is not an edit screen (including when they edit a ticket)
PKS.setReadOnly(false)
PKS.setRequired(true)
}
Deleted user October 26, 2018

Clever solution! That works for me!

Thanks a lot.

(I think I'll open up a bug report for this though as this should be able to work like in my example I think)

TAGS
AUG Leaders

Atlassian Community Events