This may seem weird but I am using a scripted field to get the sum total of (budget) - (spend to-date) - (accrual) to the scripted field (Remaining Budget). The problem is we're using Portfolio and Portfolio wont display scripted fields. So I think that I need to create a listener that will update a number custom field with the results from the scripted field (Remaining Budget). Can someone please help.
Thanks.
Hi @Eric Sebian
Please check https://library.adaptavist.com
There you can find a lot of example and working scripts that you can easily modify. I did it few times and save a lot of time
Regards,
Sebastian
I checked there, but unfortunately I'm not familiar with groovy scripting but I'll try. Thanks for the link.
Below is what I'm using so far to calculate the scripted field. What I need now is a way to take that calculated value of the scripted field and copy it to a custom field. I'd like to do all of this within the scripted field Is it possible? :
import com.atlassian.jira.component.ComponentAccessordef aval = getCustomFieldValue("Budget")def bval = getCustomFieldValue("Accruals")def cval = getCustomFieldValue("Spend to-date")
// check both fields contain valid numeric values and if not set them to 0if (aval == null) {aval = 0}if (bval == null) {bval = 0}if (aval != null && bval != null){return cval - bval - aval} else {// return to some code to indicate a null value in one of the fieldsreturn 0}
If you need to set field value you should use
issue.setCustomFieldValue(field, value)
Hi Eric
Considering that you don't have much experience with Groovy scripting, this webinar might be useful to you: https://www.adaptavist.com/webinars/groovy-scripting-for-scriptrunner/
thanks.
thanks. I watched some of it and it explains a few things that I didnt know before.
This is good to hear
https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-using-a-listener
It looks like you're new here. Sign in or register to get started.