Hi I try to set the original estimate on a issue base on some field value.
For exemple if client give us the size of his business we need to add more time to the estimate.
I've been working on this for some time now and it still does not work so maybe the community might be able to help me.
here is my code at the moment
import com.onresolve.jira.groovy.user.FieldBehaviours;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.onresolve.jira.groovy.user.FieldBehaviours ;
import groovy.transform.BaseScript ;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.TimeTrackingSystemField;
import com.atlassian.jira.issue.IssueInputParameters
@BaseScript FieldBehaviours fieldBehaviours
Issue issue = event.issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def myIssueManager = ComponentAccessor.getIssueManager();
// Get la valeur du field Solex
int flagSolexId = 12903
CustomField flagSolex = customFieldManager.getCustomFieldObject(flagSolexId)
def flagSolex_value = issue.getCustomFieldValue(flagSolex)
def flagSolexEstimate = 0
//Get la valeur du field Entente Financiere
int ententeFiId = 12902
CustomField ententeFi = customFieldManager.getCustomFieldObject(ententeFiId)
def ententeFi_value = issue.getCustomFieldValue(ententeFi)
def ententeFiEstimate = 0
// Get la valeur du field nb employés
int nbEmployeeId = 11725
CustomField nbEmployee = customFieldManager.getCustomFieldObject(nbEmployeeId)
def nbEmployee_value = issue.getCustomFieldValue(nbEmployee) as Integer
def nbEmployeeEstimate = 0
// Get la valeur du field nb questions
int nbQuestionsId = 11726
CustomField nbQuestions = customFieldManager.getCustomFieldObject(nbQuestionsId)
def nbQuestions_value = issue.getCustomFieldValue(nbQuestions) as Integer
def nbQuestionsEstimate = 0
// Get la valeur du field flex
int flexId = 11748
CustomField flex = customFieldManager.getCustomFieldObject(flexId)
def flex_value = issue.getCustomFieldValue(flex)
def flexEstimate = 0
// Get la valeur du cachier de charge
int cahierChargeId = 11729
CustomField cahierCharge = customFieldManager.getCustomFieldObject(cahierChargeId)
def cahierCharge_value = issue.getCustomFieldValue(cahierCharge)
def cahierChargeEstimate = 0
// Get la valeur du lourdeur
int lourdeurId = 11730
CustomField lourdeur = customFieldManager.getCustomFieldObject(lourdeurId)
def lourdeur_value = issue.getCustomFieldValue(lourdeur)
def lourdeurEstimate = 0
//attitre une valeur pour la variable flagSolexEstimate
if (flagSolex_value == 'Solex') {
flagSolexEstimate = 0
}
else {
flagSolexEstimate = 1
}
//attitre une valeur pour la variable enteteFiEstimate
if (ententeFi_value =='NON'){
ententeFiEstimate = 0
}
else {
ententeFiEstimate = 1
}
//attitre une baleur pour la variable nbEmployeeEstimate
if (nbEmployee_value >= 250 ){
nbEmployeeEstimate = 1
}
else{
nbEmployeeEstimate = 0
}
//attitre une baleur pour la variable nbQuestionEstimate
if (nbQuestions_value >= 11 ){
nbQuestionsEstimate = 1
}
else{
nbQuestionsEstimate = 0
}
//attitre une valeur pour la variable flexEstimate
if (flex_value == "O" ){
flexEstimate = 1
}
else{
flexEstimate = 0
}
//attitre une valeur pour la variable cahierChargeEstimate
if (cahierCharge_value == "O" ){
cahierChargeEstimate = 1
}
else{
cahierChargeEstimate = 0
}
//attitre une valeur pour la variable lourdeurEstimate
if (lourdeur_value == "O" ){
lourdeurEstimate = 2
}
else{
lourdeurEstimate = 0
}
def totalEstimate = flagSolexEstimate + ententeFiEstimate + nbEmployeeEstimate + flexEstimate + cahierChargeEstimate as Integer
int original_value = (totalEstimate * 1440)
int remain_value = (totalEstimate * 1440)
issue.setOriginalAndRemainingEstimate(Long original_value, Long remain_value )
If someone can juste help me with a working exemple to update the original estimate I can clean my messy code
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.