Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error in creating a sub-task for jira 6

Priya Thevar December 9, 2013

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("***");

9 answers

1 vote
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2013

use this to get user object

User user=ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();

Priya Thevar December 16, 2013

Thank you for the help.

Priya Thevar December 16, 2013

What import statement has to be used for this? I am not getting the method getDirectoryUser() in IDE. It says cannot resolve symbol getDirectoryUser()

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2013

you have to use following dependencies in pom.xml

&lt;dependency&gt;
&lt;groupId&gt;com.atlassian.jira&lt;/groupId&gt;
&lt;artifactId&gt;jira-core&lt;/artifactId&gt;
&lt;version&gt;${jira.version}&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.atlassian.jira&lt;/groupId&gt;
&lt;artifactId&gt;jira-api&lt;/artifactId&gt;
&lt;version&gt;${jira.version}&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;

0 votes
Priya Thevar December 17, 2013

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.

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2013
I don't know groovy syntax, but I just modified your code as below:

//Linking the issue with parent

Map&lt;String,Object&gt; newIssueParams = ["issue":newSubtask] as Map&lt;String,Object&gt;;

log.warn("\n\n\nnewIssueParams: ---&gt; ${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("***");
0 votes
Priya Thevar December 15, 2013

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)

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2013

you just try using User as a String object rather than User object

0 votes
Priya Thevar December 15, 2013

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'

0 votes
Priya Thevar December 15, 2013

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'

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2013

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)

Priya Thevar December 16, 2013

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?

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2013

you declare User using
import com.atlassian.crowd.embedded.api.User;

0 votes
John Bishop
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 9, 2013

I'm not sure what your code's issue is, but jiraAuthenticationContext.getUser(); is deprecated. You should probably change it to jiraAuthenticationContext.getLoggedInUser();.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events