Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

using IssueManager.createIssue() from velocity

Lance Wong
Contributor
June 30, 2011

im trying to create a new issue programmatically from a velocity template using the createIssue() method from IssueManager

#set ($theUser = $authcontext.getUser())

#set ($theFields = $map.build("project", "10040", "reporter", "juser", "assignee", "juser", "type", "12", "summary", "the test issue"))

$myIssueMgr.createIssue($theUser, $theFields)

but i cannot seem to figure out how to populate $theFields, createIssue always spits back a nullpointer exception. The issue type that im trying to create has the required fields of issue-type, reporter and summary which i have included. The project id and type id i have verified as correct. I have verified that $myIssueMgr, $theUser and $theFields are valid objects. So now im stuck. Maybe im not formatting the map-value-pairs correctly? Any suggestions are welcomed!

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Brad Baker [Atlassian]
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2011

Why do this from Velocity itself. Velocity templates are ment for display purposes pretty much.

Why not call back onto some Java code and do it type safely and deliberately, even if that is called from Velocity (which is still a bit weird. Why would you create an issue as the result of generating some view output?)

I suggest you also usethe IssueService. The IssueManager is the old way of doing it and will one day not be supported as an API.

Lance Wong
Contributor
June 30, 2011

until i get my dev environment fixed, using velocity templates seemed the quickest way to insert code into a workflow. Ill look at IssueService. thx!

Lance Wong
Contributor
June 30, 2011

using IssueService worked! alot less code than i expected too. horray

0 votes
Lance Wong
Contributor
June 30, 2011

i tried "issuetype" instead of "type", didnt change things. I got "type" from the entitymodel.xml mentioned in the create() method in the IssueManager API. But it looks like ill be trying the IssueService object instead. Having said that, ill hold off on posting the huge stack trace... :)

0 votes
Jobin Kuruvilla [Adaptavist]
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.
June 30, 2011

Can you post the stakctrace here? Also the issue type key is issuetype I guess and not type.

Lance Wong
Contributor
June 30, 2011

i tried "issuetype" instead of "type" but that didnt change anything. I got "type" from the entitymodel.xml mentioned in the IssueManager API. But it looks like ill be trying IssueService object instead... so ill hold off on posting the ugly stacktrace :)

Jobin Kuruvilla [Adaptavist]
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.
June 30, 2011

Trying out issueService is definitely the best option. But check out the IssueFieldConstants class when in doubt (like when using IssueManager) on what to put as the key for fields!

TAGS
AUG Leaders

Atlassian Community Events