Hi,
I'm trying to create few subtasks based on custom field values. For example if i select 2 users in user pick(multiple), two sub tasks to be created and assigned to that users selected along with main tasks(this is not yet implemented as of now). Im just creating a sub task with static values. Here is the steps followed
public void execute(Map transientVars, Map args, PropertySet ps)
throws WorkflowException {
MutableIssue issue = getIssue(transientVars);
IssueInputParameters issueSubtaskParams = issueService.newIssueInputParameters();
issueSubtaskParams.setSummary("Testing...");
issueSubtaskParams.setProjectId(issue.getProjectObject().getId());
issueSubtaskParams.setIssueTypeId("5");
CreateValidationResult validationResult = issueService.validateSubTaskCreate(user,issue.getId(), issueSubtaskParams);
IssueService.IssueResult issueResult = issueService.create(user, validationResult);
}
}
2. Added this post function after "Creates the issue originally." here is the order
When i try creating issue, the above code keeps create the subtasks in infinite loop. Please guide me how to avoid this issue.
Your code is recursing, with the subtask issue creation triggering another call to the code every time. Try creating a new workflow that does not use your post-function, and associate that with the subtasks, OR, in your code, add something like "if issue.getType() = subtask, then exit without trying to create anything"
Hi Nic Brough
While creating sub tasks, im trying to set assignee and security level for the issue. But those values have been overridden automatically after executing this line
issueService.validateSubTaskCreate(user,issue.getId(), issueSubtaskParams);
any idea?
Here is the code snippet
issueSubtaskParams.setAssigneeId(vendor.getName());
Collection<IssueSecurityLevel> islmc =islm.getAllSecurityLevelsForUser(vendor.getDirectoryUser());
for (IssueSecurityLevel issueSecurityLevel : islmc) {
issueSubtaskParams.setSecurityLevelId(issueSecurityLevel.getId());
break;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I'm not sure what vendor.getName() would do, but my best guess is that it's not returning a user object that the assignee field would take. For the security level, it won't work. Subtasks have the same security level as their parent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic, Thanks for the answer. I could see the username if inspect vendor.getName() line. Im pretty sure it returns username and setAssignee() accepts string only. #2: How do i restrict the access to subtasks of each individual vendors. for example, Vendors should not be able to see the subtasks each other whereas main task and all subtasks can be accessed by the user who creates them. how do i achieve it? Will be helpful if you provide some inputs on this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, yes, the api for setAssignee does say "user" or "string" (I've only ever used user, so I didn't know about string). Problem is, I don't know what that string might be. I'd take a guess at login id rather than name. On the security, there's no easy way to do it - the security level comes from the parent. You *might* be able to do it if you added a custom field for "vendor" (a group?), added that to the subtask and used it in the security scheme, but I'm not sure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.