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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

script runner calculated field Edited

Hi all,

Does anyone can help me. I'm quite new in scripting...

I need to get a value from a calculated field (number field) and multiply it by 250


I'm using this for a field with the value "5":

import com.atlassian.jira.component.ComponentAccessor;
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10102");
def value = (String)issue.getCustomFieldValue(customField);

return value * 250


But the result is:



tks for any help


2 answers

1 accepted

0 votes
Answer accepted

Try to convert your value to a double before making math operation:

return value.toDouble() * 250

Or get it as a double in the first place

def value = (Double)issue.getCustomFieldValue(customField);

Tks Peter.

this works fine

return value.toDouble() * 250

Buenas Tardes, 

alguien me puede ayudar?.

Estaba creando un script para ponerlo como condicion en una transaccion, consiste en que si el customfield (Fecha), es menor que el dia 25 del mes actual me deje validar la issue sino no, el problema es que lo meto en conditions se me ejecuta pero no me hace nada.



import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import java.sql.Timestamp
import com.atlassian.jira.issue.MutableIssue
import java.util.Date
import java.text.SimpleDateFormat
import java.text.DateFormat

//MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject('MANI-8')
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManafer = ComponentAccessor.getIssueManager()
def userManager = (UserManager) ComponentAccessor.getUserManager()

CustomField cfFecha = customFieldManager.getCustomFieldObjectByName("Fecha")

def valorFecha = (String)issue.getCustomFieldValue(cfFecha)
def diaCustomField=valorFecha.substring(8,10)
def mesCustomField=valorFecha.substring(5,7)

def currentDate = new Date ()
def fechaActual=currentDate.dateString
def mesActual= fechaActual.substring(3,5)

if (diaActual <= '25' && diaCustomField <= '25' && mesCustomField==mesActual || diaCustomField >= '25' && mesCustomField != mesActual ) {
return true
else {
return false

While it may work, I don't think it's a good idea to use<= on a string value, I'd recommend you work with integers.

You don't need to convert your date to sting then parse it with substring, just use the built-in date object methods like getDate() and getMonth()

For example

def currentDate = new Date().minus(10)
def valorFecha = issue.getCustomFieldValue(cfFecha)

return ( <= 25 && <= 25 && currentDate.month == valorFecha.month || >=25 && currentDate.month != valorFecha.month)

Here are all the different permutation with example dates for the logic statement:

today=30Apr, Cf = 30Apr > false (same month /no date<25)
today=30Apr, Cf = 15Apr > false (same month /cf date<25)
today=15Apr, Cf = 30Apr > false (same month /today date<25)
today=15Apr, Cf = 15Apr > true  (same month /both dates<25)

today=30Apr, Cf = 15May > false  (different month /cf date<25)
today=15Apr, Cf = 30Apr > true (different month /cf date !<25)
today=15Apr, Cf = 15May > false (different month /both dates <25) 

Suggest an answer

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

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

62 views 1 7
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