Hi,
I want to display sum of two number fields to third number field.
ex: 1 Support Count CRM(2.0) = 510
2 Support Count CRM(Old) = 10
3 Support Count CRM(New) = 4
Calculate the sum of 2 custom fields (2+3) to the third custom field (1)
First you create the script field and place it on whatever screen you need it on, then go to manage apps and you'll be able to find it under Scriptrunner > Fields :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Assuming they are all 'Number Fields' this approach should work.
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject("ITSD-57")
def number1Value = customFieldManager.getCustomFieldObjectsByName("Number 1")[0].getValue(issue)
def number2Value = customFieldManager.getCustomFieldObjectsByName("Number 2")[0].getValue(issue)
def number3Field = customFieldManager.getCustomFieldObjectsByName("Number 3")[0]
def number3Value = number1Value + number2Value
number3Field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(number3Field), number3Value), new DefaultIssueChangeHolder())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mathis Hellensberg - So again do i need to create any script field?
if script field not required then where do i update the script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could very well do it in a scriptet field :)
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def number1Value = customFieldManager.getCustomFieldObjectsByName("Number 1")[0].getValue(issue)
def number2Value = customFieldManager.getCustomFieldObjectsByName("Number 2")[0].getValue(issue)
number1Value + number2Value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.