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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,557,830
Community Members
 
Community Events
184
Community Groups

Make field optional ONLY on create issue screen

Deleted user Oct 09, 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

1 vote
Answer accepted

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 Oct 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)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events