Time Tracking fields (Original Estimated, Remaining Estimation) copy to another field by calculation

Sai Krishna Yadav
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!
September 12, 2023

Time Tracking fields (Original Estimated, Remaining Estimation) copy to another field by calculation (1h = 3600S). Created scripted field template as duration(Timetracking) and add this below script

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.core.util.DateUtils
import java.sql.Timestamp

// Get the issue
//def issue = issue

// Get the remaining estimate in seconds
def result = 0

// Perform the calculations
def issueEstimate = issue.originalEstimate
if (issueEstimate) {
result = issueEstimate * 3600
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// Set the result to a custom field (change 'customFieldName' to your custom field name)
def customFieldName = "Estimate (used for Kiplot Automation)"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName(customFieldName)
issue.setCustomFieldValue(customField, result)
}
if (customField) {
    issue.setCustomFieldValue(customField, result)
}

return result
Please help me on this.
Thanks,
Sai

1 answer

0 votes
Jeroen Poismans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2023

Hello and Welcome to the Atlassian Community,

I can see two things happening here in the code:

 issue.setCustomFieldValue(customField, result)

And 

return result

 

As I understand it this is code for a scripted field? If so only he return statement sets the value on this scripted field. 

What are you trying to do? What does not work as expected?

Regards,

Jeroen

Suggest an answer

Log in or Sign up to answer