Forums

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

Scriptrunner field

Sen Meh
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 14, 2024

Hi

We are currently in the migration process and i am trying to re-write a script runner field in cloud. There is a xyz custom fields which tells the total of all these below fields.

Script in on-prem:

def NewCustomers = getCustomFieldValue("Direct sales potential new customers") as Float
def ExistingCustomers = getCustomFieldValue("Direct sales potential existing customers") as Float
def Prerequisite = getCustomFieldValue("Feature is a prerequisite for sales to new/existing customers") as Float
def Impact = getCustomFieldValue("Strategic Impact ATOSS") as Float
def Maintenance = getCustomFieldValue("Maintenance downtime/escalation") as Float
def COS = getCustomFieldValue("COS - Reduction of operating expenses") as Float
def CSS = getCustomFieldValue("CSS - Reduction of implementation effort") as Float


return (0.15 * (NewCustomers ?: 0) +
0.15 * (ExistingCustomers ?: 0) +
0.15 * (Prerequisite ?: 0) +
0.25 * (Impact ?: 0) +
0.10 * (Maintenance ?: 0) +
0.10 * (COS ?: 0) +
0.10 * (CSS ?: 0)
)

in the above section all are the custom fields with number text field. 
I am having problems to migrate it and showing the total number of the fields. 
Thanks

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Champion
February 14, 2024

Hi Sen,

I can confirm that in Cloud currently, scripted fields show under a specific section for scripted fields, but we are currently working on making scripted fields actual custom fields.

This will be released shortly, and you should watch the Release Notes pages to see when it is released.

As for the script in Jira Cloud, you will need to access the fields using the rest APIs which Jira Cloud provides and have an example of using a script listener to calculate a custom field on issue update, which sums up a series of number fields and returns the total.

This example will need to be modified just to return the summed value as scripted fields need to return a value to be shown on the issue, and we have a scripted field to sum up story points on an issue example here, which shows this.

You can use these examples as a reference to help write the script you require for your scripted field.

I hope this information helps.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer