I am getting the following error while creating a sub-ask on the create transition of a issue. Script was working fine in jira 5. After upgrading to jira 6 I get the following errors for users.
No signature of method: com.atlassian.jira.issue.managers.DefaultIssueManager.createIssueObject()
Pls help
this is the code to link the subtask
-----------------------------------------------------------------------------------------------------
//Linking the issue with parent
Map<String,Object> newIssueParams = ["issue":newSubtask] as Map<String,Object>;
log.warn("\n\n\nnewIssueParams: ---> ${newIssueParams.dump()}\n\n\n"); //Debug the parameters
//Get the user who is currently logged in
def currentUser = jiraAuthenticationContext.getUser();
log.warn("\n\n\n******\n\n\n");
//creating the issue that links the subtask and the current User
newSubtaskGV = issueManager.createIssueObject(currentUser,newIssueParams);
log.warn("***");
//reindexing
indexManager.reIndex(newSubtaskGV);
log.warn("***");
//link the subtask with the parent issue
subTaskManager.createSubTaskIssueLink(EmpIssue, newSubtask, componentManager.getJiraAuthenticationContext().getUser());
log.warn("Subtask ${newSubtask.getKey()} is created from ${issue.getKey()}");
log.warn("You're fine till here");
log.warn("\n\n");
issueLinkManager.createIssueLink(issue.getId(),newSubtask.getId(),Long.parseLong(linkID),0,user)
ComponentManager.getInstance().getIndexManager().reIndex(newSubtask)
---------------------------------------------------------------------------------------------------
Script stops because of this line
//creating the issue that links the subtask and the current User
newSubtaskGV = issueManager.createIssueObject(currentUser,newIssueParams);
log.warn("***");
use this to get user object
User user=ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What import statement has to be used for this? I am not getting the method getDirectoryUser() in IDE. It says cannot resolve symbol
getDirectoryUser()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to use following dependencies in pom.xml
<dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-core</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency>
<dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-api</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got the answer to this
def public CreateSubtask(MutableIssue issue, String mySummary, User newassign)
{
CustomField cfemp = customFieldManager.getCustomFieldObjectByName( "Employee");
DelegatingApplicationUser cfempv = issue.getCustomFieldValue(cfemp);
User empuser = cfempv.getDirectoryUser();
}
CreateSubtask(issue, "Profile Creation - Resume",empuser);
This works in jira 6 without any errors of typecasting.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know groovy syntax, but I just modified your code as below: //Linking the issue with parent Map<String,Object> newIssueParams = ["issue":newSubtask] as Map<String,Object>; log.warn("\n\n\nnewIssueParams: ---> ${newIssueParams.dump()}\n\n\n"); //Debug the parameters //Get the user who is currently logged in def currentUser = jiraAuthenticationContext.getUser(); log.warn("\n\n\n******\n\n\n"); //creating the issue that links the subtask and the current User newSubtaskGV = issueManager.createIssueObject(currentUser.getName(),newIssueParams); log.warn("***"); //reindexing indexManager.reIndex(newSubtaskGV); log.warn("***"); //link the subtask with the parent issue subTaskManager.createSubTaskIssueLink(EmpIssue, newSubtask, ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser()); log.warn("Subtask ${newSubtask.getKey()} is created from ${issue.getKey()}"); log.warn("You're fine till here"); log.warn("\n\n"); issueLinkManager.createIssueLink(issue.getId(),newSubtask.getId(),Long.parseLong(linkID),0,user)// also you check which user you are giving it should be ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser() ComponentManager.getInstance().getIndexManager().reIndex(newSubtask) --------------------------------------------------------------------------------------------------- Script stops because of this line //creating the issue that links the subtask and the current User newSubtaskGV = issueManager.createIssueObject(currentUser,newIssueParams); log.warn("***");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tied using it as a string. It says
No signature of method: com.onresolve.jira.groovy.postfunction.Script5.CreateSubtask() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl, java.lang.String, com.atlassian.jira.user.BridgedDirectoryUser) values: [SCS-1355, Assign owner for BDM -, admin:1]
Possible solutions: CreateSubtask(com.atlassian.jira.issue.MutableIssue, java.lang.String, java.lang.String)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you just try using User as a String object rather than User object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm getting this error for Users
The script failed : javax.script.ScriptException: javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'admin(admin)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting this error for Users
The script failed : javax.script.ScriptException: javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'admin(admin)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Priya,
I think you should pass a user in String type. see https://docs.atlassian.com/jira/6.0/com/atlassian/jira/issue/IssueManager.html#createIssueObject(java.lang.String, java.util.Map)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am facing another problem in jira 6.
def public CreateSubtask(MutableIssue issue, String mySummary, User newassign )
{
CustomField cfemp = customFieldManager.getCustomFieldObjectByName( "Employee" );
User cfempv = issue.getCustomFieldValue(cfemp);
log.warn("Employee issue assignee :" +cfempv);
}
CreateSubtask(issue, "Profile Creation - Resume",cfempv);
This gives the following error
java.lang.ClassCastException: com.atlassian.jira.user.DelegatingApplicationUser cannot be cast to com.atlassian.crowd.embedded.api.User
Any solution how do I pass the User parameter in CreateSubtask?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you declare User using
import com.atlassian.crowd.embedded.api.User;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure what your code's issue is, but jiraAuthenticationContext.getUser(); is deprecated. You should probably change it to jiraAuthenticationContext.getLoggedInUser();.
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.