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

Using Script Runner to Update Custom Date Field

Charles Chien April 22, 2014

Is there a way to determine whether a custom field was updated during an edit (not workflow transition)? Basically, I want to update a scripted field to the current date if customfield_##### was updated during the edit. Thanks.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2014

Hello,

you could write a simple script that manage ISSUE_UPDATED event. During the issue update this field could be set to the current date.

Hope this helps,

Fabio

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2014

import com.opensymphony.workflow.WorkflowContext

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.event.issue.AbstractIssueEventListener

import com.atlassian.jira.event.issue.IssueEvent

import org.apache.log4j.Logger

import static org.apache.log4j.Level.DEBUG

import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult

import com.atlassian.jira.bc.issue.IssueService.IssueResult

import com.atlassian.jira.bc.issue.IssueService

import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult

import com.atlassian.jira.issue.IssueInputParametersImpl

import com.atlassian.jira.issue.IssueInputParameters

import com.atlassian.jira.util.ErrorCollection

import com.atlassian.jira.issue.index.IssueIndexManager

class invoketransition extends AbstractIssueEventListener {

Logger log = Logger.getLogger(invoketransition.class)

@Override

void issueUpdated (IssueEvent event) {

log.setLevel(org.apache.log4j.Level.DEBUG)

def field = event.getChangeLog().getRelated('ChildChangeItem').any{ it.field.toString().equalsIgnoreCase("fieldname")}

if (field){

//your code

}

}

}

TAGS
AUG Leaders

Atlassian Community Events