Hi.
I have two custom fields on the screen. If I select Yes in one Custom Field It needs to be Yes in another custom field and it should pop an error. How to achieve this.?????
Hi Frank,
If you have Behaviours (Script Runner) installed - this is possible using this plugin.
@Peter Bengov I do have behavior plugins. Please guide me
Try something like this:
import com.atlassian.jira.component.ComponentAccessordef customFieldManager = ComponentAccessor.getCustomFieldManager();String customField1Name = "XXX";String customField2Name = "YYY";String cf1ValueToCheck = "Yes";String errorToShow;def cf1;def cf1FieldValue;cf1 = getFieldByName(customField1Name);cf1FieldValue = cf1.getValue();if ((cf1FieldValue != null) && (cf1FieldValue.toString() == cf1ValueToCheck)) { cf2.setRequired(true);}
@Peter Bengov
I tried something like this
import org.apache.log4j.Category;import com.atlassian.jira.ComponentManager;import com.opensymphony.workflow.InvalidInputException;import com.atlassian.jira.ComponentManager;import com.atlassian.jira.issue.CustomFieldManager;import com.atlassian.jira.issue.Issue;import com.atlassian.jira.issue.MutableIssue;import com.atlassian.jira.issue.comments.CommentManager;import com.atlassian.jira.issue.fields.CustomField;import com.atlassian.jira.util.ImportUtils;import com.opensymphony.util.TextUtilsimport com.atlassian.jira.component.ComponentAccessor;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customField_1 = customFieldManager.getCustomFieldObject("customfield_18900");CustomField customField_2 = customFieldManager.getCustomFieldObject("customfield_18509");
if (issue.getCustomFieldValue( customField_1 ) == "Yes") { issue.getCustomFieldValue( customField_2 ) == "Yes"}else {throw new InvalidInputException("If Approval? is Yes, Approval Attached needs to be Yes to proceed")}
Even though I set two custom fields to Yes, I am still getting the error
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();CustomField customField_1 = customFieldManager.getCustomFieldObject("customfield_18900");CustomField customField_2 = customFieldManager.getCustomFieldObject("customfield_18509");
if (issue.getCustomFieldValue( customField_1 ) == "Yes") { issue.getCustomFieldValue( customField_2 ) == "Yes"}else {throw new InvalidInputException("If Approval Required? is Yes, Approval Attached needs to be Yes to proceed")}
Eventhough, I set the two fields to Yes, I still see the error.
It looks like you're new here. Sign in or register to get started.