I have written this api to create issues in JIRA
public boolean creteIssue(String deliverable, String productName){ ApplicationUser applicationUser = authenticationContext.getUser(); IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); // issueInputParameters.setSummary(req.getParameter("deliverable")); //issueInputParameters.setDescription(req.getParameter("deliverable")); issueInputParameters.setSummary(deliverable); issueInputParameters.setDescription(deliverable); issueInputParameters.setAssigneeId(applicationUser.getName()); issueInputParameters.setReporterId(applicationUser.getName()); String projectKey = leangearsDiscoveryAction.getProjectKey(productName); Project project = projectService.getProjectByKey(applicationUser, projectKey).getProject(); issueInputParameters.setProjectId(project.getId()); issueInputParameters.setIssueTypeId("2"); currentUser = authenticationContext.getLoggedInUser(); IssueService.CreateValidationResult result = issueService.validateCreate(currentUser, issueInputParameters); issueService.create(currentUser, result); return true; }
Now I am trying to call this function from my velocity template.
$action.creteIssue($discoverDeliverablesConfs.get($k).deliverable,$prod)
But it is not working. What should be the correct approach?
Community moderators have prevented the ability to post new answers.
Try $action.creteIssue("$discoverDeliverablesConfs.get($k).deliverable" , "$prod")
If it does not help try to hard code string params for creteIssue method. I guess that the problem is with resolving the strings. Also check that the plugin reloaded and your newly created "creteIssue" method was compiled. You can run atlas-clean to be sure.
Your suggestion of debugging this helped a lot as there was problem with the method invocation. It is working fine now but it creates the issue every time I reload the page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> but it creates the issue every time I reload the page Because this is what you coded: the method is called every time the page is loaded. You either need to persist somewhere that the issue for passed deliverable and productName is already created or in your method do a search for the issue created based on passed deliverable and productName and create it only if does not exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was trying with this as well but then the whole layout goes for a toss <button class="aui-button aui-button-link" id="delv" onclick=$action.createIssue("$dev_feature" , "$prod")>Create Issue</button>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, you are mixing JavaScript and Java code :-). createIssue method will be called anyway when the page is rendered. You need some persisted flag to indicate that issue is already created and do not the createIssue when the flag is set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr, is it possible to save the Issue Id once the issue is created ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alok, sure issue.getId() see javadoc: https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/Issue.html
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.
Method itself is not getting called. $action.creteIssue($discoverDeliverablesConfs.get($k).deliverable,$prod) itself is getting printed on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you debug the method? Is it invoked? If it's invoked: do you get any exception.
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.