Hi Eric,
Where do you execute this code? Is it a scripted postfunction?
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.
The ideal solution would allow a user to select multiple "Field Sites" (multiselect insight field), create subtasks for each of those selections, then add the Field Site object to the correct subtask.
For example:
User selects field sites: Atlanta, New York, DC
Subtask for Atlanta with field site object "Atlanta"
Subtask for New York with field site object "New York"
Subtask for DC with field site object "DC"
Does that make sense?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Getting close!!!
I have the script creating subtasks based on a jira multiselect list. I really need to convert that to an Insight multiselect field and copy attributes into the summary field of the newly created subtask.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def customFieldManager = ComponentAccessor.customFieldManager
def cf = customFieldManager.getCustomFieldObjectByName("Multiselect Field Sites") // This needs to me changed to a multiselect Insight field
def summariesList = (issue.getCustomFieldValue(cf) as Collection<Option>)*.value
Issue parentIssue = issue
//if the parent issue type name IS NOT Task - do nothing
if (parentIssue.getIssueType().getName() != 'Task')
return
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def groupManager = ComponentAccessor.getGroupManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def subTaskManager = ComponentAccessor.getSubTaskManager()
summariesList.each { subTaskSummary ->
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary(subTaskSummary + ": " + issue.getSummary())
newSubTask.setParentObject(parentIssue)
newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find {
it.getName() == "Sub-task"
}.id)
// Add any other fields you want for the newly created sub task
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
issueManager.createIssueObject(user, newIssueParams)
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Just use the custom field value and create the issues on the projects that you have selected.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_xxxxx");
if (issue.getCustomFieldValue(cf) == null) {
/* No objects selected */
return;
}
issue.getCustomFieldValue(cf).each{projectObject ->
def name = projectObject.getName();
/* Create the issue code depending on
the project name or any attribute
sepecified on the objects */
}
You can also look into the Insight JAVA API if you need to get more information stored as attributes on the objects.
Look at https://documentation.riada.se
Cheers //Mathias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am receiving an error at
def name = projectObject.getName();
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.
Hello Eric
That error could be that the console doesn't know what class projectObject is.
Could you save the script and try to see if it works, even though it gives you that inline error?
Cheers
Dyelamos
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Eric.
This could be done through a custom script on the console.
I don't think we offer this kind of functionality. This is some pretty custom stuff.
If i were you I would load the data through a JSON and send it through a SR Rest Endpoint. That's your safest bet.
Hope this helps.
Cheers!
Dyelamos
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.