I am new to script runner, please help me on below requirement.
Scriptrunner has great documentation and recipe examples.
Scriptrunner docs Scripted Fields
What you might find even more helpful is the library.
Scriptrunner Library
There's actually a great example that should get you started in the library here:
calculate-custom-field-on-issue-update
Hope this helps.
Thank you for providing all the details.
Here is my script, but it gives some random value in field2 (worked total hours). Could you please check it and modify it if I have missed something.
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
def issueManager = ComponentAccessor.getIssueManager()
def linkManager = ComponentAccessor.getIssueLinkManager()
def cfm = ComponentAccessor.getCustomFieldManager()
Issue issueKey = issue
def id=issueKey.getId()
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf = customFieldManager.getCustomFieldObject("customfield_18849")
def cff = customFieldManager.getCustomFieldObject("customfield_18844")
def n = Integer.parseInt((issue.getCustomFieldValue(cf) ?: 0).toString().replaceAll(~/[.].*/, ""))
def b = Integer.parseInt((issue.getCustomFieldValue(cff) ?: 0).toString().replaceAll(~/[.].*/, ""))
Integer sum = (n ?: 0) + (b ?: 0);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, that's the code for calculating 2 custom fields and populating that value into a 3rd field(a scripted field, this is the code for that scripted field).
Where are you using this code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am using this code in the scripted custom field2 (customfield_18849) and populating the calculation value in this field2 only.
field1 is editable but field2 is noneditable.
I need the calculated value of field1 and field2 to be populated in field2.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Craig Nodwell Thank you. I am just waiting for your response.
In case my previous question wasn't entirely clear, I would like to repeat my request once more.
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.