Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using Jira cloud & script runner creating a calculated scripted field with error

I created 5 numeric custom fields for the HELPDESK project. These fields are not used for every ticket in the project, but when they are used all 5 are mandatory.

I have a 6th numeric custom field and using script runner I am trying to fill this field based on an equation from the 5 fields. 

I am using jira cloud so finding a solution on REST API. 

(I am not a developer)


Getting the below Error:

The scripted field ran successfully, but returned an invalid type. Please return a number    null



def input1CfId = 'customfield_10046'
def input2CfId = 'customfield_10047'
def input3CfId = 'customfield_10048'
def input4CfId = 'customfield_10049'
def input5CfId = 'customfield_10050'
def outputCfId = 'customfield_10060'
def projectKey = "HELPDESK"

def input1 = issue.fields[input1CfId] as Integer
def input2 = issue.fields[input2CfId] as Integer
def input3 = issue.fields[input3CfId] as Integer
def input4 = issue.fields[input4CfId] as Integer
def input5 = issue.fields[input5CfId] as Integer

if (input1 == null || input2 == null || input3 == null || input4 == null || input5 == null) {"Calculation using ${input1}, ${input2}, ${input3}, ${input4}, and ${input5} was not possible")
return 0

def output = input1 * input2 * input3 * input4 * input5

if (output == (issue.fields[outputCfId] as Integer)) {"already been updated")

//.queryString("overrideScreenSecurity", Boolean.TRUE)
.header("Content-Type", "application/json")
(outputCfId): output as Integer


Can someone help me please?

1 answer

0 votes

The error message and the last line of your script combine to explain it.  The last line says "asString()", which converts the output to a string.  But you've set the field to be a number.

You just need to line up the types of output.

Sorry Nic, could you please help further? I am not familiar with coding.

You either need to target a text field for the output, or have your script return a number.  To do the second, remove the .asString as a start

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

479 views 5 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you