Forums

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

Creating Script Field of using template "Date"

Raju Kadam
March 11, 2020

We need to display first value that Date field was set. Steps that I've are:

  1. From Change History, get 1st Change for this field
  2. Later using the Formatter object, convert it into a Date object.
  3. Return the formatted date to display using *Date* Template

 

{code}

//Find out date when device was deployed 1st time!

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*
import java.text.SimpleDateFormat;

def last_deployed_date_first_change_item = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "Last Deployed Date").first()

def formatter = new SimpleDateFormat("yyyy-MM-dd")
def first_deployed_date = formatter.parse(last_deployed_date_first_change_item?.to)
formatter.format(first_deployed_date)
{code}

 

When Date template selected, it throws $dateFormatterWithoutTime.format($value) error. But with Text Field (multi-line) it just works fine.

Since we need Date object that can be used in JQL later, we would like to create a field of type Date.

Let's know what's wrong with the script.

2 answers

0 votes
Tarun Sapra
Community Champion
October 6, 2013

it's a network firewall issue which is causing SSO to act wierdly and we are working on it.

0 votes
Jobin Kuruvilla [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 Champions.
September 30, 2013

Do you have SSO enabled? Are there any other apps from Atlassian using SSO along with JIRA? I have seen this issue when SSO is mis-configured.

If you clear browser cookies, are you able to login without checking the remember me box?

Tarun Sapra
Community Champion
September 30, 2013

Yes SSO is enabled, our test environment is also using the same crowd. I tried to login without the checkbox ticked in the chrome incognito browser still no luck, i have to check the tickbox only then it works.

Jobin Kuruvilla [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 Champions.
September 30, 2013

I wouldn't use the test JIRA with the same Crowd, especially if the domain is different. Try switching off Test JIRA and see if that makes any difference!

There must be something wrong in the configuration.

Suggest an answer

Log in or Sign up to answer