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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set a date customfield or choice list custom field with the IssueInputParameters ?


My request is very simple :

I want to set customfield values during a transition by groovy script. I'm able to do this with text customfield, like this :

IssueInputParameters issueInputParameters = new IssueInputParametersImpl();

issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_13700","All Closed");
issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_12704",issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12704")));

This code works for text customfields, but not for date or choice list customfields.
I heard that for choice list customfields, I have to use the option ID, but I have not tried yet.

Is anyone can help me ?

Thank you.

10 answers

1 accepted

0 votes
Answer accepted

This code should works but it doesn't :

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
date = sdf.format(issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10203")))
issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_10203",date);

Does anyone know what is the ".0" after "2013-04-24 00:00:00" ? it seems to be milliseconds number, but event with

SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S") or SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"), it does not work.

You should try the format which is displayed in JIRA while you edit a date field.

It works, thank you Henning and Jamie ;)

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy") (for me)

as by this works, I do not recommend it.

As it does not take care of different time zones and therefore will be very creative when storing the date fields.

date fields don't have a "time" component, so it's not really important. If you're adding 7 days to a date, the timezone is not relevant.

DateTimeFormatter formater = this.dateTimeFormatterFactory.formatter().forUser(user);
Date dueDate = new Date();
String dueDateFormated = formater.format(dueDate); issueImput.Parameters.setDueDate(dueDateFormated);

Hi Lubos,

I get error with your code. Maybe I'm missing an import or a base script declaration?

dateTimeFormatterFactory is declared in a dynamic context, but you tried to access it from a static context.

When I change it to

DateTimeFormatter formatter = ComponentAccessor.getComponent(DateTimeFormatter)
DateTimeFormatter userFormatter = formatter.forUser(user)
Date myDate = new Date()
String dateFormatted = userFormatter.format(myDate)

I get the output format like "Just now" but not the input format for the date picker fields. Please check my answer for use of DateFieldFormat.

For issueInputParameters you need a String representation of the content of the field. So for a select customfield you have to get the value of the option.

issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_12705",issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_12705")).getValue());

For dates I think you have to have a valid String representation of a date for your system, but I'm not sure, I didn't tried that.


Yes... generally it matches what the browser sends. Examples for date and datetimes etc:

inputParameters.with {
	setOriginalAndRemainingEstimate("4d", "3d")
	setDueDate "18/Nov/12"
	setSummary "updated summary"

	addCustomFieldValue(myNumberField.idAsLong, 3 as String)
	addCustomFieldValue(firstDate.idAsLong, "3/Jan/2012")
	addCustomFieldValue(firstDateTime.idAsLong, "30/Jan/13 10:53 PM")

Hi Henning,

Thank you for your help.

I found for select customfield, with this code :

issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_10205",issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10205")).getOptionId().toString());

For the date issue, I tried to get a date customfield value and to cast it to String, but it didn't work ...

A cast won't work, use a SimpleDateFormat to convert to a string. But you may need to check the default date format that your jira uses. There should be a simpler way, but I don't know what it is.

Jumping into an old thread in case it helps someone in the future. The way I was ultimately able to work around this was by ending my code with:

def update = issueService.validateUpdate(user,, issueInputParameters)

if (update.isValid()) {
issueService.update(user, update)


this returned

INFO : Errors: {customfield_27220=Invalid date format. Please enter the date in the format "dd/MMM/yy h:mm a".}
Error Messages: []

So I knew I needed to use SimpleDateFormat("dd/MMM/yy h:mm a") for my date. Hope this helps someone!

When I get the date customfield value, it returns this format : "2013-04-24 00:00:00.0"

I didn't solve my problem for date custofield.

But I can show how I did for multiple select list ! Here is the code I use :

def varargsMethod(String ... args){

potentialImpactOptions = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10905"))
Set potentialImpactOptionsID = new HashSet();
    for(Option option : potentialImpactOptions){
	   temp = option.getOptionId().toString();
def potentialImpactArray = varargsMethod( potentialImpactOptionsID as String[] );
issueInputParameters = issueInputParameters.addCustomFieldValue("customfield_10905",potentialImpactArray);

Has anyone figured out how to set a cascading select field in Jira 6?

I can set the parent option, but I can't figured out how to set both parent and child in one call.

This works to set the parent ...


I've tried all of the following to set parent/child together, but to no avail:

issueInputParameters.addCustomFieldValue(myField.getIdAsLong(),"10637", "10640");

issueInputParameters.addCustomFieldValue(myField.getIdAsLong(),"10637, 10640");

issueInputParameters.addCustomFieldValue(myField.getIdAsLong(),"10637 10640");



Is this really not documented anywhere?

I am able to get this to work using customField.updateValue together with IssueManager.updateIssue using the code outlined by Eddie Web on this page:

But that seems old school...

This is how I managed to do just that (and lost 2 days figuring it out):

issueInputParameters.addCustomFieldValue("customfield_" + fieldId, parentOption.getOptionId().toString());
issueInputParameters.addCustomFieldValue("customfield_" + fieldId + ":1", childOption.getOptionId().toString());

Thanks for the tip Mladen!

I went a little rogue and added a TBD section on this page. I was hoping it would trigger an atlassian to do something about the information vacuum on this subject. Not a peep so far.

do not forget to set up 

issueInputParameters.setSkipScreenCheck(true) if target issue edit screen not contains customfield 


I know this question is quite old but I found that here is missing a good solution since different Jira instances have different input formats and I worried that my code would break, if this input format will change at some day.

I found the DateFieldFormat class in the API:

With this I changed my code to

final DateFieldFormat dateFieldFormat = ComponentAccessor.getComponent(DateFieldFormat)
issueInputParameters.with {
addCustomFieldValue(myDatePickerField.idAsLong, dateFieldFormat.formatDatePicker(myDate))

I hope this helps anyone who is looking for a solution for this problem.


Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you