im trying to create a new issue programmatically from a velocity template using the createIssue() method from IssueManager
#set ($theUser = $authcontext.getUser())
$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!
Community moderators have prevented the ability to post new answers.
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
using IssueService worked! alot less code than i expected too. horray
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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... :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post the stakctrace here? Also the issue type key is issuetype I guess and not type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.