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

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

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

 

Thanks,

Sumit

Hi Sumit, Where is the script??

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

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"));

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Amir Kazemi
Posted an hour ago in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

9 views 0 2
Join discussion

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