why is my createValidationResult wrong? And why is the ErrorCollection empty?

I'm trying to create subTasks to an Issue.

In my code I create the Issue first and then I try to create SubTasks via issueService.validateSubTaskCreate(.....) and so on.

when I run my plugin it creates the normal Issue just like I intended. but gives me an exeption:

java.lang.IllegalStateException: You can not create an issue with an invalid validation result.

I've tried different things up until now. I tried getErrorCollection() on the validationResult, which came back empty. But when I tried isValid() it returned false and I have no idea why since I did everything like I did with the main Issue

 
here's what I did:
public List<IssueInputParameters> subTaskParameters(Issue newIssue, Issue oldIssue){
    	List<IssueInputParameters> newParams = new ArrayList();
    	List<Issue> currentSubTasks = (List<Issue>) oldIssue.getSubTaskObjects();
    	
    	for(Issue issue : currentSubTasks){
    		IssueInputParameters input = issueService.newIssueInputParameters();
    		
    		input.setDescription(issue.getDescription());
    		input.setIssueTypeId(issue.getIssueTypeObject().getId());
    		input.setProjectId(issue.getProjectObject().getId());
   			input.setSummary(issue.getSummary());
   			input.setAssigneeId(getLoggedInUser().getDisplayName());
   			newParams.add(input);
    	}
    	
    	return newParams;
    }
    public void createSubTasks(Issue newIssue, Issue oldIssue){
    	List<IssueInputParameters> subTaskParams = subTaskParameters(newIssue, oldIssue);
    	
    	for(IssueInputParameters params : subTaskParams){
        	CreateValidationResult createValidationResult = issueService.validateSubTaskCreate(getLoggedInUser(), newIssue.getId(), params);
        	IssueResult result = issueService.create(getLoggedInUser(), createValidationResult);
           	}
    }

 Thanks beforehand.

2 answers

1 accepted

This widget could not be displayed.

Alright! I got it. just forgot to set the Reporter^^

This widget could not be displayed.

Could it be failing because the parent issue is not created by the time you get to the subtasks? I think that might cause a validation failure with no actual results (it used to in version 3)

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

189 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you