Forums

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

Scripted field not returning value

Ajith Shandilya August 7, 2019

Below is the script for adding two types of cost to get total cost. I want to know what is the issue with the script as no value is returned 

// Required Imports
import com.atlassian.jira.component.ComponentAccessor

// Get a pointer to my Custom Field Manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// Ensure that the script field does not store cached values and always dynamically re calculates the values every time a page is laoded.
enableCache = {-> false}

// Only execute on feature issues
if ( (issue.issueType.name == "Portfolio Epic") || (issue.issueType.name == "Portfolio Enabler")) {

// Get the required value from the cost of delay Scripted Field
def elc = getCustomFieldValue("Estimated Labor Cost") as Double;
def eoc = getCustomFieldValue("Estimated Other Cost") as Double;

if (elc > 0 && eoc >= 0) {

// Create total cost
def dbletc = elc + eoc as Double;

}
return dblelc.round();
}

1 answer

0 votes
Payne
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 7, 2019

I notice a typo that may be your source of grief. You assign a value to dbletc but return dblelc.

Ajith Shandilya August 7, 2019

@Payne ,

Good catch! but that didn't resolve the issue. Actually we are facing issue with other scripted fields which used to work before. I have submitted a ticket to Adaptavist and waiting for response. We updated the script runner a week before

Suggest an answer

Log in or Sign up to answer