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.?????
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.TextUtils
import 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 Required? is Yes, Approval Attached needs to be Yes to proceed")
}
Eventhough, I set the two fields to Yes, I still see the error.
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.TextUtils
import 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Frank,
If you have Behaviours (Script Runner) installed - this is possible using this plugin.
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.
Try something like this:
import com.atlassian.jira.component.ComponentAccessor
def 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);
}
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.