You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.