Hi All,
I have a script and currently its showing output value in Number like 0, 12, 123 but I want to show the output like $0, $12, $123.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser
import java.text.NumberFormat
def issueManager = ComponentAccessor.getIssueManager()
def linkManager = ComponentAccessor.getIssueLinkManager()
def cfm = ComponentAccessor.getCustomFieldManager()
Issue issueKey = issue
def id=issueKey.getId()
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf1 = customFieldManager.getCustomFieldObject(29041)
def cf2 = customFieldManager.getCustomFieldObject(29042)
def cf3 = customFieldManager.getCustomFieldObject(29043)
def cf4 = customFieldManager.getCustomFieldObject(30304)
def n = Integer.parseInt((issue.getCustomFieldValue(cf1) ?: 0).toString().replaceAll(~/[.].*/, ""))
def b = Integer.parseInt((issue.getCustomFieldValue(cf2) ?: 0).toString().replaceAll(~/[.].*/, ""))
def c = Integer.parseInt((issue.getCustomFieldValue(cf3) ?: 0).toString().replaceAll(~/[.].*/, ""))
def d = Integer.parseInt((issue.getCustomFieldValue(cf4) ?: 0).toString().replaceAll(~/[.].*/, ""))
Integer sum = (n ?: 0) + (b ?: 0) + (c ?: 0) + (d ?: 0);
Added the below script and it works as expected.
def decimalFormat = new DecimalFormat("###,###")
def formattedSum = "\$" + decimalFormat.format(sum)
return formattedSum
Could you please share a screenshot of your Scripted Field configuration so I can better understand the field type you are using?
If you have set the Scripted Field to Number Field type, then it is not doable because the number field will only take Numbers and Decimal points.
However, if you are using the Text Field, then yes, you can add the $ symbol.
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So add a dollar to it and return it as String?
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.