Hi Team!
Help me please for my problem :(
We need that fields calculated ("stp","def_prod") and write sum in fields ("adm","total").
We have this script in behaviour plugin:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
//Take fields by name
def stp = getFieldByName("cf1Name");
def adm = getFieldByName("cf2Name");
def total = getFieldByName("cf3Name");
def def_prod = getFieldByName("cf4Name");
//Take the value from the field and assign the type Double
def value_stp = stp.getValue() as Double
def value_def = def_prod.getValue() as Double
if (value_stp != null & value_def != null){
def sum_adm = (value_stp + value_def) * 0.15
adm.setFormValue(sum_adm)
total.setFormValue(value_stp + sum_adm)
}
else {
//Set null if value_stp\value_def = null
adm.setFormValue(null)
total.setFormValue(null)
}
Values are calculate. But after delete value fields ("stp", "def_prod") "adm" and "total" is not set null.
How cleaning Double field's value in Behaviour?
Thanks!
Best
Regards
I found error in my script.
When i cleared my custom fields they have type "String".
When i write value they have type "Double".
Because of this condition "if" not work and value in customfield not cleared.
Below correcte script:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
def stp = getFieldByName("cfName");
def adm = getFieldByName("cf2Name");
def total = getFieldByName("cf3Name");
def def_prod = getFieldByName("cf4Name");
if (stp.getValue() != "" && def_prod.getValue() != ""){
def sum_adm = ((stp.getValue() as Double) + (def_prod.getValue() as Double)) * 0.15
adm.setFormValue(sum_adm)
total.setFormValue((stp.getValue() as Double) + sum_adm)
}
else {
adm.setFormValue(null)
total.setFormValue(null)
}
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.