Forums

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

setRequired(false) failure

zhangqian04
Contributor
May 31, 2020
My requirement is: When XXX is selected for a field, the link is not required, otherwise it is required.

def phaseField = getFieldById(getFieldChanged())
def selectedOption = phaseField.getValue() as String
def linkid = getFieldById("issuelinks")

if(selectedOption != "XXX" ){
linkid.setRequired(true)
}
else{
linkid.setRequired(false)
}

The execution result is: when XXX is selected for a field, the question display of setting link is not required (that is, there is no red meter before the field), but it is still prompted to be required when submitting

 

2 answers

1 accepted

0 votes
Answer accepted
zhangqian04
Contributor
July 7, 2020

The latest version 6.4.0 has been resolved

0 votes
PD Sheehan
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.
June 1, 2020

If required is still prompted when you submit, check your workflow validators and your project's field configuration. 

If it is required in either of those places, you can not make it not required using  setRequired(false) 

Also, shortcut:

linkid.setRequired( selectedOption != 'XXX') //instead of it/then/else
zhangqian04
Contributor
June 1, 2020

First of all, thank you for your answer.

I  checked  workflow validators and  project's field configuration, they are not special configuration.

In addition,When submitting, setrequire fail, I try to switch repeatedly the "issue type" on the current creation page, then submit it to take effect.

It seems to trigger a page refresh.

Suggest an answer

Log in or Sign up to answer