Hi,
I need to update my custom field value for every 24 hours. So I decided to use scheduled jobs but I couldn't use update function here. It's throwing error whenever I'm trying to update the custom field value from here. Added to this, I can't select more than one user name in scheduled jobs. I expect this program should allow 5 users to run it.
Can anyone please help me out
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import java.sql.Timestamp
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
JiraServiceContext sourceUserServiceCtx = new JiraServiceContextImpl(user)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def issue = event.getIssue() as MutableIssue
def event = event as IssueEvent;
def issuetype = issue.getIssueType()
def changeHolder = new DefaultIssueChangeHolder()
def now = new Timestamp(new Date().getTime())
def field = customFieldManager.getCustomFieldObjectByName("custom field name")
def fieldValue = issue.getCustomFieldValue(field)
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field),now),changeHolder)
}
}
Thanks in advance
Your script is throwing errors because you have not told it to do a lot, and you have got invalid calls in it. I think you have misunderstood the job definition as well. A job is a block of code that runs regularly in Jira.
So the misunderstandings here seem to be
So, I would take a step back and think through:
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.