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

Hi, I want to add two customfield values and have to display that in another customfield.



I want to add two customfield values and have to display that in another customfield. for example, in our project we have 3 fields called TEST1, TEST2 and TEST3. Want to add Test1 and Test2 and that has to be displayed in Test3. These 3 fields are number fields. Can you please share any codes to perform this ?  And after that, the value of TEST3 , we have to show that in the dashboard. 



2 answers

1 vote
Leo Community Leader Dec 06, 2019

Hi @Nirmala,

You can go with scriptrunner's behaviour  which will capture value from another field and set another field value in the same screen

def field1 = getFieldByName("Test1")
def field2 = getFieldByName("Test2")
def field3 = getFieldByName("Test3")

def value1 = field1.getFormValue() as Double
def value2 = field2.getFormValue() as Double
def value = value1 + value2


I haven't tried this code, it may need some minor changes 




0 votes
Elifcan Cakmak Community Leader Dec 06, 2019


Something like this should work:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//def issue = issueManager.getIssueObject("OT-3")
def userManager = ComponentAccessor.getUserManager()
def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def user = authenticationContext.getLoggedInUser()

def test3CF = customFieldManager.getCustomFieldObject("customfield_10240") //change cf id
def test1CF = customFieldManager.getCustomFieldObject("customfield_10323") //change cf id
def test2CF = customFieldManager.getCustomFieldObject("customfield_10324") //change cf id

def test1value = test2CF.getValue(issue) == null ? 0 : test1CF.getValue(issue)
def test2value = test2CF.getValue(issue) == null ? 0 : test2CF.getValue(issue)

def test3value = (double)test1value + (double)test2value

issue.setCustomFieldValue(test3CF, test3value)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

return test3value





Can you please suggest where to add these condition ,like in the workflow or is this something different? Because i'm new to this. 



Elifcan Cakmak Community Leader Dec 06, 2019


You can add it to the postfunction of your workflow if it will be only updated via transition. Or you can add it as script listener that listens to issue updated event and updates whenever one of these two customfield changes.




But we are trying to populate this on the create screen itself. is that be possible to display the total value in the create screen itself with non editable one. because we have to display that in the dashboard. Can you please suggest any idea for this?





Is there any  comment for this?



Elifcan Cakmak Community Leader Dec 30, 2019


Sorry, I didn't see your comment. You can use @Leo 's solution or use a script field that comes from Script Runner plugin. Script field also shows the changes on the same screen as far as I know.



Suggest an answer

Log in or Sign up to answer

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