So here is the script. I omitted some code, but ideally this is how it is. My main issue is that when I run the "issueManager.updateIssue" function the issue's due date does not get updated. However in the history, it does say the change value was update.
Is this the proper to way to do this?
//manager to manage ineractions with issue
IssueManager issueManager = ComponentAccessor.issueManager
//user context of who is working on this ticket
ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey("issuebot")
//the database view of an issue
Issue nonMutableIssue = event.getIssue()
MutableIssue mutableIssue = issueManager.getIssueObject(event.issue.getKey())
//print orignal dute date before change
//make the change
c.setTime(*SOME RANDOME TIME SET*)
String dateStr = (c.get(Calendar.MONTH) + 1) + "/" + c.get(Calendar.DAY_OF_MONTH) + "/" + c.get(Calendar.YEAR)
log.info TAG + "${mutableIssue.getKey()} due date set to: ${dateStr}"
mutableIssue.setDueDate(new Timestamp(c.getTimeInMillis()))
//updates the changes to the issue in the database
def updatedIssue = issueManager.updateIssue(user, mutableIssue, EventDispatchOption.ISSUE_UPDATED, false)
//run a reindex to get the latest changes made from the database
event.issue.reindex();
I used the base part of your code to reproduce this, but in our instance (Jira DC 9.9.1) this works:
The actual code:
import java.sql.Timestamp
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = event.getIssue() as MutableIssue
Timestamp newDueDate = Timestamp.valueOf("2023-10-23 10:10:10.0");
issue.setDueDate(newDueDate)
def user = Users.getLoggedInUser() as ApplicationUser
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
Does "the update don't go into the DB" mean, that in your issue view the due date field is incorrect and not set to the value that your listener should set?
Do you see any log lines in atlassian-jira.log about that?
Thank you for taking the time and helping me out.
I looked more into the problem and discovered these two errors:
[o.c.g.runtime.m12n.MetaInfExtensionModule] Module [Innovalog Groovy extensions for JIRA] - Unable to load extension class [org.codehaus.groovy.runtime.SqlGroovyMethods]
[c.a.j.cache.request.RequestCacheRecorderImpl] Invalid use of RequestCache by thread: default-application-role-manager-cache-refresh.Incorrect usage of JIRA API.
After a little more research I found out that the plugin "JSU automation suite for jira workflows" is the reason why I could not update the fields to the database. Once I disabled the plugin, the fields were updated to the database. It seems like JSU is causing something to mess up when the issue gets created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wow, great catch. Than it's up to the plugin vendor I'd say :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Abi and welcome,
your code seems correct infact you see due date field correctly updated in the issue history.
Based on issue history, is due date updaed again? If so, there is something else that happens after your operation.
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the quick response.
Based on the issue history, the due date does not get updated again. There are no other listeners/post-functions that run after the listener.
A little more context. This custom listener runs when the issue is created. The due date is initially set when the issue is created by the user. I can see that in the database when I go to view the record of it. Then the listener runs, and updates the due date's value. But the value is not written to the database.
The Issue object returned from "IssueManager.updateIssue()" should ideally be the reindexed and stored updated issue. But its not the same as "event.issue" object, which ideally should be.
I have read about google and tried the HAPI way of updating the issue, but even that doesnt work!!!
I even tried using the other way of "IssueManager.updateIssue()" passing in a
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on the Issue history, there are no transactions that show the due date being removed. The due date is original set by the issue creator. When the customer listener runs when the issue gets created, the original due still stays the same even after a transaction log of the due date is being shown.
I have exhausted all attempts of using "IssueManager.updatedIssue" function and even using the other method of passing in a "
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.