Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,671
Community Members
 
Community Events
184
Community Groups

Custom listener - events fired on

Hi,

I have a custom listener that when a checkbox is ticked, a custom date & time field is updated.

The script works when the event is set to "issue updated", however, within the workflow the checkbox appears as a field on a screen and you transition to the next step of the workflow. If I click the checkbox there, it does not update the custom date & time field.

However, if I click to edit the issue and click the checkbox then, then the custom date & time field is updated accordingly. 

I tried the event "CustomFieldUpdatedEvent" but it still won't update the custom date & time field when the checkbox is presented on a screen.

I am not sure if that is the code or a specific event to be fired on?

Code as below:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
 
import java.sql.Timestamp
 
Issue issue = issue
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Goods Handed Over"}
if (change) {
    def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Goods Handed Over Timestamp")
    def changeHolder = new DefaultIssueChangeHolder()
    def now = new Timestamp(new Date().getTime())
    cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), now),changeHolder)
}

 

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Aug 16, 2022

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events