Hi,
I am trying to set the story points automatically based on multiple custom field values. The values are identified but the issue is when I run it in the groovy console the value is getting set but when I try to set it via post function the function doesn't work. I am getting the below error.
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setFieldValue() is applicable for argument types: (String, Integer) values: [Aha! Rank, 4]
Regards,
Sunil
Hi @G Sunil Kumar ,
please look here for the example.
I would change
def StoryPointsV = customFieldManager.getCustomFieldObject(StoryPoints).toString()
to
def StoryPointsV = customFieldManager.getCustomFieldObject(StoryPoints)
And
issue.setFieldValue(StoryPointsV, sum)
To
issue.setCustomFieldValue(StoryPointsV, sum)
Which type does you custom field customfield_10008 have? You will also probably need to convert the story points to float before setting the value to the custom field.
I actually tried the above changes but work, the script runs successfully but the data is not reflecting.
customfield_10008 is a number field can you suggest how I can covert?
Regards,
Sunil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The functionality depends on the order of your post functions. There's no store functionality in your script, so this groovy post function needs to be executed before issue is stored to the database (Update change history for an issue and store the issue in the database). Please check...
According to conversion - you should be able to do only simple:
issue.setCustomFieldValue(StoryPointsV, sum as float)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Hana Kučerová ,
Thank You.
But that also didnt work as I took a different approach and used JMWE plugin and it is working.
Regards,
Sunil
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.
-------------------------------------------------------------
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def log = Logger.getLogger("com.onresolve.scriptrunner.runner.ScriptRunnerImpl")
log.setLevel(Level.INFO)
def TimeSaved = "Time Saved"
def Technology = "Technology"
def TimeToRespond = "Time to Respond"
def Function = "Function"
def StoryPoints = "customfield_10008"
def StoryPointsV = customFieldManager.getCustomFieldObject(StoryPoints).toString()
def TimeSavedV = customFieldManager.getCustomFieldObjectsByName(TimeSaved);
def TimeSavedV2 = issue.getCustomFieldValue(TimeSavedV).toString()
log.info("The time saved value is " + TimeSavedV2)
def TechnologyV = customFieldManager.getCustomFieldObjectsByName(Technology);
def TechnologyV2 = issue.getCustomFieldValue(TechnologyV).toString()
log.info("The technology value is " + TechnologyV2)
def TimeToRespondV = customFieldManager.getCustomFieldObjectsByName(TimeToRespond);
def TimeToRespondV2 = issue.getCustomFieldValue(TimeToRespondV).toString()
log.info("The Time to respond value is " + TimeToRespondV2)
def FunctionV = customFieldManager.getCustomFieldObjectsByName(Function);
def FunctionV2 = issue.getCustomFieldValue(FunctionV).toString()
log.info("The time save value is " + FunctionV2)
def a = [:]
if (TimeSavedV2 == "1-17 hours per week") {
a = Integer.parseInt((1 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
else if (TimeSavedV2 == "18-35 hours per week") {
a = parseInt(2 ?: 0).toString()
}
else if(TimeSavedV2 == "36+ hours per week") {
a = parseInt(3 ?: 0).toString()
}
else {
a = Integer.parseInt((4 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
log.info("The value is a " + a)
def b = [:]
if (TechnologyV2 == "Yes") {
b = Integer.parseInt((1 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
else {
b = Integer.parseInt((0 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
log.info("The value is b " + b)
def c = [:]
if (TimeToRespondV2 == "10-25%") {
c = Integer.parseInt((1 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
else if (TimeToRespondV2 == "25-50%") {
c = Integer.parseInt(2 ?: 0).toString()
}
else if(TimeToRespondV2 == "50%+") {
c = Integer.parseInt((3 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
else{
c = Integer.parseInt((4 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
log.info("The value is c " + c)
def d = [:]
if (FunctionV2 == "Yes") {
d = Integer.parseInt((1 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
else {
d = Integer.parseInt((0 ?: 0).toString().replaceAll(~/[.].*/, ""))
}
log.info("The value is d " + d)
Integer sum = (a ?: 0) + (b ?: 0) + (c ?: 0) + (d ?: 0)
log.info ("The value of sum is" + sum)
issue.setFieldValue(StoryPointsV, sum)
----------------------------------------------------------
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.