Hi
I've seen a bunch of examples with slightly different requirements. But my requirement is on a transition that 5 different issue types can go down, to only check two of them for BOTH levels of a cascading field to be filled in.
For example:
If Issue type = Service Request
then
Both levels of 'Service Request Type' cascading field need to be filled in
if Issue Type = Incident
then
Both levels of 'Incident Type' cascading field need to be filled in.
and to not worry about the other 3 issue types.
I managed to fish out this example from Googling around for the cascading field requirements, but I need to know how to how to make it only check depending on the issue type
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue def issue = issue as MutableIssue def cascadingSelect = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)?.findByName("Service Request Type") def values = issue.getCustomFieldValue(cascadingSelect) as HashMap // Will return true if both the parent and child options in the Cascading Select have a value values?.keySet()?.size() == 2
Hi
After a bunch of testing, this seems to only be paying attention to the first if statement, especially if I try and split it out to get two different error messages in the simple scripted validator.
It doesn't seem to be checking for your invalid input message
Hi @Stephen Letch,
The following custom script validator may guide you;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField incidentTypeCF = customFieldManager.getCustomFieldObject("customfield_XXXXX");
if(issue.getIssueTypeId().equals("12345")){ // Incident Issue Type ID
if(issue.getCustomFieldValue(incidentTypeCF)?.values()*.value[0] == null
|| issue.getCustomFieldValue(incidentTypeCF)?.values()*.value[1] == null){
invalidInputException = new InvalidInputException("Please fill both cascading values..")
}
}
CustomField serviceRequestTypeCF = customFieldManager.getCustomFieldObject("customfield_XXXXX");
if(issue.getIssueTypeId().equals("54321")){ // Service Request Issue Type ID
if(issue.getCustomFieldValue(serviceRequestTypeCF)?.values()*.value[0] == null
|| issue.getCustomFieldValue(serviceRequestTypeCF)?.values()*.value[1] == null){
invalidInputException = new InvalidInputException("Please fill both cascading values..")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Getting errors on creation and also doesnt seem to stop the transition
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField incidentTypeCF = customFieldManager.getCustomFieldObject("customfield_11428");
if(issue.getIssueTypeId().equals("10103")){ // Incident Issue Type ID
if(issue.getCustomFieldValue(incidentTypeCF)?.values()*.value[0] == null
|| issue.getCustomFieldValue(incidentTypeCF)?.values()*.value[1] == null){
invalidInputException = new InvalidInputException("Please fill both cascading values..")
}
}
CustomField serviceRequestTypeCF = customFieldManager.getCustomFieldObject("customfield_11417");
if(issue.getIssueTypeId().equals("10104")){ // Service Request Issue Type ID
if(issue.getCustomFieldValue(serviceRequestTypeCF)?.values()*.value[0] == null
|| issue.getCustomFieldValue(serviceRequestTypeCF)?.values()*.value[1] == null){
invalidInputException = new InvalidInputException("Please fill both cascading values..")
}
}
EEDIT: It worked when I changed
ccustomfield_11428 to Incident
EDIT 2: It doesn't seem to be paying attention to the invalidinput area and also if it s a simple scripted one it requires you to fill in the error field below anyway. If you use custom script so that it might use the invalidinput message then none of it blocks anything.
Think I'm going to split it up into two validators so it can show the separate messages depending on context, thanks very much though, this has helped a lot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.