I'm using Jira software and the Secure Fields plugin. Three custom fields to do a simple calculation: the budget that remains when you subtract the spent budget from the initial budget.
My code is this, and it's embedded in a Script Runner behavior.
Since I've noticed that if by mistake a value in the custom field is deleted, it takes the value "null", this means that the custom field is no longer shown in the screen and above all it happens that it is not considered in my code that in fact no longer does the subtraction.
How can I do, I ask for help, to make it so that it runs a control like: if the customfield is equal to "null" then value it to "zero"?
So that after that the subtraction can be performed correctly ?
Double totalBudget = Double.valueOf(""+getFieldById("customfield_12101").getValue())
Double spentBudget = Double.valueOf(""+getFieldById("customfield_12400").getValue())
def remainingBudget = totalBudget - spentBudget;
getFieldById("customfield_12402").setFormValue(remainingBudget)
Heya @[deleted]
I'm not too familiar with Secure Fields and how they would interact with ScriptRunner, but would something like this help?
if (remainingBudget == null)
{getFieldById("customfield_12402").setFormValue("0")}
else
{getFieldById("customfield_12402").setFormValue(remainingBudget)}
I'm not quite sure what custom field type 12402 is, but hope this might work as a potential workaround.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tye Joe Wai I started from your example and then with subsequent modifications, I eventually solved the problem. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted] there could be simple fix but Code seems quite complicated to me. What is the type of custom fields
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.