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.

9 answers

1 accepted

0 votes
Accepted answer

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.

Henning Tietgens Community Champion Apr 23, 2013

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.

1 vote
Henning Tietgens Community Champion Apr 23, 2013

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!

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

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 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,714 views 17 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you