Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a custom date for a specific resoluition

Jeff Abbott February 2, 2022

I need to set a a custom date field (Date Returned), when a Resolution is set to "Rework Needed".  I am unclear where to do this. Post Functions do not appear to be the correct location.

2 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
February 2, 2022

This definitely is a job for a post-function (or automation), but you'll need an app to do it.

A post-function is more than capable of running on the "move issue to done" transition where you ask the user to choose a resolution, take a look at what they choose, and then setting a (presumably future) date on it.

Also possible with (again a scripted/custom) listener, but a post-function is the best option - easiest code and most efficient.

0 votes
Tim Perrault
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.
February 2, 2022

Hi @Jeff Abbott 

 

I'm not sure this can be done without using an app from the marketplace. Do you have any apps added on to your instance?

 

Thanks,

Tim

Jeff Abbott February 9, 2022

I got this working using ScriptRunner.  I use a post function to set the appropriate data field after each transition. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.workflow.IssueWorkflowManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
import java.sql.Timestamp
import com.atlassian.jira.event.type.EventDispatchOption

log.setLevel(Level.DEBUG);

// Field ID: 10900

def issueManager = ComponentAccessor.getIssueManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def user = issue.getCreator()
def dateCf = customFieldManager.getCustomFieldObject(10900)

issue.setCustomFieldValue(dateCf, new Timestamp((new Date()).time))
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Like Tim Perrault likes this
Jeff Abbott February 28, 2022

@Tim Perrault , I used Script Runner

Suggest an answer

Log in or Sign up to answer