Forums

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

How to make a custom field mandatory in a particular status ?

Shivi Gupta June 3, 2020

Note : I don't want to make a field mandatory during a status transition , but when it is on a particular status .

For eg : Status = In Progress , Custom field is optional 

             Status = Pending , Custom field is mandatory

2 answers

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2020

Hi Shivi,

A status transition and saying once a field moves into a particular status is the same thing. 

You should put a Validator on the transition to the Pending status to make the field required. 

Shivi Gupta June 5, 2020

I don't think its same ..

For E.g. : If from To Do -> In Progress , only user can move it and the issue assigned to is a developer  , So he will be responsible to fill out that custom field which I want to make mandatory . If I put validator only that transition , user will be asked to fill out that mandatory field , while I want developer to fill that field .

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 5, 2020

That's different information that what was in the question - thank you for the clarification.

How will you know if the user is a Developer? 

Shivi Gupta June 7, 2020

Hi @John Funk 

User is a different role and Developer is different . The status transitions are restricted according to the user roles and permissions . 

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 8, 2020

Since you already have different transitions, just put the validator on the one for Developers 

0 votes
Jose Luis Casarrubias June 3, 2020

Do you mean, once ticket transition is completed to Pending, if ticket is edited, certain custom field is mandarory due to status = Pending?

Shivi Gupta June 5, 2020

Yes ...I meant the same 

Jose Luis Casarrubias June 5, 2020

Ok, if this is the case, I think you accomplish this with a Behaviour script. 

You can read about them here

 

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

If I have a chance I will give you the idea of the script tomorrow

Jose Luis Casarrubias June 5, 2020

Here it is an example of Behaviour script

def cf_status = getFieldById("status")
def cf_field = getFieldByName("yourfieldName")

String status = cf_status.getValue()

if (status.equalsIgnoreCase("Pending")) {
cf_field.setRequired(true)
}

else {
cf_field.setRequired(false)
}

Shivi Gupta June 7, 2020

Hi @Jose Luis Casarrubias 

I tried this but it is not working . The field is not showing as mandatory when status is "Pending".

Jose Luis Casarrubias June 7, 2020

Hi,

Can you please share the script you are using?

Shivi Gupta June 17, 2020

Hi @Jose Luis Casarrubias 

I am using the same script which you have shared . Apologies for late reply !

Jose Luis Casarrubias June 19, 2020

Hello @Shivi Gupta 

Sorry for the late.

Here it is the correct script.

In my example, I will do the Tester customfield mandatory only when ticket is in Accepted status.

This script was placed as a Behaviour script for the Tester customfield.
Behaviour initializer should be left empty.

def cf_field = getFieldByName("Tester")

String status = underlyingIssue.getStatus().name

if (status.equalsIgnoreCase("ACCEPTED")) {
cf_field.setRequired(true)
}

else {
cf_field.setRequired(false)
}

After saving the behavior, I just test the behavior trying to Edit a ticket. If ticket is in Accepted status, the field shows a red "*" to imply the field is mandatory. If ticket is in a different status, the red "*" is not shown and the field is not mandatory.

Please check on your side and let me know.

Regards,

Jose Luis

Suggest an answer

Log in or Sign up to answer