Please tell me what is wrong with this script? It is returning NULL.
Requirement: Need to update the value of a custom field from NULL to the value specified in the script.
----------------------------------------------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
def fieldid = 14601L //field id; currently having null value
def dbValue = "8.0.8" //New value to be assigned to the custom field
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TIK-3039"); //issue in JIRA
MutableIssue myIssue = issue;
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(fieldid); //Identification of Custom Field Object
myIssue.setCustomFieldValue(customField,dbValue); //updating the value from "Null" to the value declared above "dbValue"
----------------------------------------------------------------------------------------------------------
Best regards,
Nishant
Hi Nishant,
Try this one
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
Long fieldid = 14601L //field id; currently having null value
def dbValue = "8.0.8" //New value to be assigned to the custom field
MutableIssue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TIK-3039"); //issue in JIRA
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(fieldid); //Identification of Custom Field Object
issue.setCustomFieldValue(customField,dbValue); //updating the value from "Null" to the value declared above "dbValue"
return (String) issue.getCustomFieldValue(customField);
Thanks Aleks for your inputs. Just a minute back only, I also did the same and it worked perfectly......I was missing the return statement!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have 3 groovy scripts- A, B and C
1. "A" calculates certain values and puts them into an array
2. "B" takes those values as inputs from A and connect to an external database and returns a value
3. "C" takes that return value from "B"
As of now, I have hard coded the values in each of the script to develop and test. However, in real time, I want them to be one script with the above dependency in place.
How I can combing them under one script? This script then will be added as a post function in JIRA.
Please help.
Thanks,
Nishant
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.