Jelly script to retrieve a Date custom field value to Jira.


I have got a custom field 'Expected Start Date' in Jira. I need to get 'Shipping Date' custom field 3 business days prior to 'Expected Start Date'. I have got this working using the below jelly script. I need to get this result date into Jira custom field as an value.

I have tried this but gave an error - Can't convert 28/Sep/12 (Note: this is the value of Shipping date that I need to get to Jira custom field) to interface com.atlassian.jira.issue.fields.CustomField

<core:invoke on="${issueKey}" method="setCustomFieldValue">
<core:arg type="com.atlassian.jira.issue.fields.CustomField" value="${formattedDate}"/>

Could someone please help?


<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
<jira:Login username="admin" password="password">

<jira:RunSearchRequest filterid="11113" var="issues"/>

<!-- Get an instance of ComponentManager -->
<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<!-- Get the IssueManager from ComponentManager -->
<core:invoke on="${componentManager}" method="getIssueManager" var="issueManager"/>

<!-- Get Custom FieldManager from ComponentManager -->
<core:invoke on="${componentManager}" method="getCustomFieldManager" var="customFieldManager"/>

<!-- Get CustomFieldObject from customFieldManager -->
<core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj1">
<core:arg type="java.lang.String" value="customfield_10049"/>

<core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj2">
<core:arg type="java.lang.String" value="customfield_11233"/>

<core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj3">
<core:arg type="java.lang.String" value="customfield_11234"/>

<!-- The current time -->
<core:invokeStatic className="java.util.Calendar" method="getInstance" var="CalendarField"/>
<core:forEach var="issue" items="${issues}">

<!-- Get the Issue from IssueManager -->
<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey">
<core:arg type="java.lang.String" value="${issue.key}"/>

<!-- Get Custom Field Value -->
<core:invoke on="${customFieldObj1}" method="getValue" var="expStartDate">
<core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issueKey}"/>

<core:invoke on="${CalendarField}" method="setTime">
<core:arg type="java.sql.Timestamp" value="${expStartDate}"/>

<core:invoke on="${CalendarField}" method="get" var="dayOfweek">
<core:arg type="int" value="7"/>

<core: set var="ExpDay" value = "${dayOfweek}"/>
<core:when test="${ExpDay == 2 || ExpDay == 3 || ExpDay == 4 }">
<core:set var="ShipDay" value="${-5}" />
<core:set var="ShipDay" value="${-3}" />

<core:invokeStatic className="java.util.Calendar" method="getInstance" var="NewCalendarField"/>

<core:invoke on="${NewCalendarField}" method="setTime">
<core:arg type="java.sql.Timestamp" value="${expStartDate}"/>

<core:invoke on="${NewCalendarField}" method="add" var="ShipStartDate">
<core:arg type="int" value="7"/>
<core:arg type="int" value="${ShipDay}" />

<core:invoke on="${NewCalendarField}" method="getTime" var="ShippingDate"/>

<core:new className="java.text.SimpleDateFormat" var="format">
<core:arg type="java.lang.String" value="dd/MMM/yy"/>

<core:invoke on="${format}" var="formattedDate" method="format">
<core:arg type="java.util.Date" value="${ShippingDate}" />


1 answer

You need to call

CustomField#updateIssue(FieldLayoutItem fieldLayoutItem, MutableIssue issue, Map fieldValueHolder)


Thank you so much for your answer. I figured it out later from other post and added it for my script to work.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

809 views 3 9
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