Hello,
We'd also like to see if we can create Rules around the reporter and stakeholder fields, i.e. if Reporter = a or b then Stakeholder = XYZ. This will save time in ticket creation and will also allow us to report out on tickets and progress more easily.
Here's a sample:
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.index.IssueIndexingService;
import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.security.IssueSecurityLevelManager;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.event.issue.IssueEventBundle
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEventBundleFactory
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueInputParameters;
import com.atlassian.jira.issue.IssueInputParametersImpl;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventDispatcher;
import com.atlassian.jira.util.ImportUtils;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import org.apache.log4j.Logger
import org.apache.log4j.Level
IssueService issueService = ComponentAccessor.getIssueService();
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext();
final IssueService.IssueResult issueResult = issueService.getIssue(authContext.getLoggedInUser(), issue.getKey());
final MutableIssue mutableIssue = issueResult.getIssue();
IssueInputParameters issueInputParameters = new IssueInputParametersImpl();
issueInputParameters.setSkipScreenCheck(true);
issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(true, true);
issueInputParameters.setSecurityLevelId(12901L);
issueInputParameters.setAssigneeId("newassignee_username");
issueInputParameters.addCustomFieldValue("customfield_XXXXX","newvalue");
IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(
authContext.getLoggedInUser(),
mutableIssue.getId(),
issueInputParameters);
if (updateValidationResult.isValid())
{
IssueService.IssueResult updateResult = issueService.update(
authContext.getLoggedInUser(),
updateValidationResult,
EventDispatchOption.DO_NOT_DISPATCH,
false );
if (updateResult.isValid())
{
//OK
}
else{
//ERR
}
}
else
{
//Validation ERROR
}
Thanks for your quick replies Gaston. Where should i add the condition to change the stakeholder custom field automatically if Reporter = John or Eric then Stakeholder = Account Advisers. I am very new to groovy scripts. I am not able to catch that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Laxmi,
this can be done by using a script post function or listner with script runner.
Do you need a code example?
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.