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
The latest version 6.4.0 has been resolved
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.