Hi,
Need help with behaviour. Below is my code, basically it sets the RL value based on the screen used. It work when creating but when editing, it should make API mandatory if the current value of RL does not contains L6
RL is a single select field. API is Element connect field.
///INITIALLIZER
import com.atlassian.jira.component.ComponentAccessor;
def RL = getFieldById("customfield_26800")
def PI = getFieldById("customfield_27801")
def RLCurrentValue
PI.setAllowInlineEdit(false)
RL.setAllowInlineEdit(false)
///sets RL CF Value based on the screen used
if (getFieldScreen().name == ("Projecte Template 1 - Initiative Screen")){
RL.setFormValue('11905')
RL.setHidden(false);
PI.setFormValue('');
PI.setHidden(true);
PI.setFormValue('');
} else if (getFieldScreen().name == ("Projecte Template 2 - Initiative Screen")) {
RL.setFormValue('')
RL.setRequired(true);
PI.setFormValue('');
PI.setHidden(true);
PI.setRequired(false);
}
///retain RL values if there's existing
if(underlyingIssue){
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjects(underlyingIssue).find{it.name == RL}
RLCurrentValue = underlyingIssue.getCustomFieldValue(cf)
} else {
RLCurrentValue = ''
}
///MAIN CODE
import com.atlassian.jira.component.ComponentAccessor;
def RL = getFieldById("customfield_26800")
def PI = getFieldById("customfield_27801")
def RLValue = RL.getValue() as String
PI.setAllowInlineEdit(false)
RL.setAllowInlineEdit(false)
//selectField.allowInlineEdit(false)
if (RLValue.contains("L6")) {
PI.setFormValue('');
PI.setHidden(true);
PI.setRequired(false);
} else {
//PI.setFormValue('');
PI.setHidden(false);
PI.setRequired(true);
}