It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hi guys,
I am trying to develop a groovy script validator on the creation of my ticket : I need to check if one of my customfield contains the good issue type values. Here is my script, I don't find my mistake and I don't know where to find error message. I have this classical error message during the creation : We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.
Here is my code :
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
MutableIssue issue = issue
IssueManager issueManager = ComponentAccessor.getIssueManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject((long) 25006)
def cfValue = issue.getCustomFieldValue(cf)
StreamAlright = true
for (int i = 0; i < cfValue.size(); i++) {
issue2 = issueManager.getIssueObject((String)cfValue[i])
if(Integer.parseInt(issue2.getIssueTypeId())!= 12800){
StreamAlright = false
break
}
}
StreamAlright != false || cfValue == null
import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.opensymphony.workflow.InvalidInputException import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue MutableIssue issue = issue IssueManager issueManager = ComponentAccessor.getIssueManager(); def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObject((long) 25006) def cfValue = issue.getCustomFieldValue(cf) StreamAlright = true for (int i = 0; i < cfValue.size(); i++) { issue2 = issueManager.getIssueObject((String)cfValue[i]) if(Integer.parseInt(issue2.getIssueTypeId())!= 12800){ StreamAlright = false break } } if (StreamAlright == true){ return true } else{ invalidInputException = new InvalidInputException("Please associate it to a Stream") }
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.