Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Behaviour plugin doesn't pickup the time value while fetching value for date time type custom field

Behaviour plugin doesn't pickup the time value while fetching value for date time type custom field

Global Tools April 8, 2015

FormField startDate=getFieldById("customfield_XXXX")

startDateValue1=startDate.getValue()

now if suppose customfield_XXXXX has value 27/Apr/15 10:30 AM.

 

I am getting startDateValue1 as Mon Apr 27 00:00:00 UTC 2015 which is missing the time part completely.


JIRA Version : 6.1.7

 

Behaviour Plugin : 0.5.10



Has anyone noticed this

Thanks in advance

 

Best Reagrds,

Sumit

 

3 answers

1 accepted

0 votes
Answer accepted
Sumit Kumar
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.
August 26, 2015

I have written a groovy script to do the needful , can close this thread now. Any research will still be an help.

 

Thanks,

Sumit

A November 3, 2015

Hi Sumit, Where is the script??

Sumit Kumar
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 1, 2016

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import java.sql.Timestamp

Logger log = Logger.getLogger("Filling EndTime")
log.setLevel(Level.DEBUG)

ComponentAccessor comAcc=new ComponentAccessor()
CustomFieldManager cfm = comAcc.getCustomFieldManager()

CustomField startTime = cfm.getCustomFieldObject('customfield_ABC') // id to be changed
CustomField endTime = cfm.getCustomFieldObject('customfield_BCD') // id to be changed
CustomField duration = cfm.getCustomFieldObject('customfield_CDE') // id to be changed


startTimeValue=issue.getCustomFieldValue(startTime)
endTimeValue=issue.getCustomFieldValue(endTime)
durationValue=issue.getCustomFieldValue(duration)

// log.debug("Updating Time")
// log.debug("startTimeValue ::: ${startTimeValue}")
// log.debug("durationValue ::: ${durationValue}")
// log.debug("endTimeValue ::: ${endTimeValue}")
long value
if (startTimeValue!=null && durationValue!=null){
value=((startTimeValue.getTime()/(1000*60)) + durationValue)*1000*60
newtime =new Timestamp(value)
def changeHolder = new DefaultIssueChangeHolder();
endTime.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(endTime), newtime),changeHolder)
}

 

return null

0 votes
Selvakumar Nagalingam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 8, 2017

Hi,

I am facing the issue. How do i get the date and time from datetime custom field?

I have a field called Release Window as dropdown (Window A, Window B) and another field RFC deployment date / time as Custom Datetime field.

If the user choose any time another than Tuesday 6 PM to Wednesday 5.30 AM, i would like to display a error message immediately. I am using behavior script to achieve this.

The issue is ld_rfcdeploymentdate returning the value only with date and time stamp is showing as 00.00.0

FormField rfcdeploymentdate = getFieldByName ("RFC Deployment Date")  

Date ld_rfcdeploymentdate = rfcdeploymentdate.getValue()

 

Window ATuesday 6:00pm - 5:30am
Window BThursday 6:00pm - 5:30am
0 votes
plugins Atlassian
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 26, 2015

Hi Jamie, I'm meeting the same issue when trying to set a default date of a date/time custom field value from another one.

Can you help us please?

FormField slaveField1 = getFieldById ("customfield_10406")
FormField masterField = getFieldById ("customfield_10404")
Date master = (Date) masterField.getValue()
slaveField1.setFormValue(master.format("dd/MM/yy HH:mm"));

Suggest an answer

Log in or Sign up to answer