Hi,
I am using the below Custom script post-function script, to set a custom field(i,e Test Managers) value to a string (i,e rrahul). But not working and getting the below ERROR, but script looks fine.
2016-11-28 16:53:45,682 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2016-11-28 16:53:45,683 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: INT-1583, actionId: 131, file: <inline script> groovy.lang.MissingPropertyException: No such property: customFieldManager for class: Script368 at Script368.run(Script368.groovy:13)
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import java.sql.Timestamp
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Defect Source'}
def cfgvalue = issue.getCustomFieldValue(cf)
if (cfgvalue == "ITG" || "MTG")
{
def cf1 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Test Managers'}
def newvalue = "rrahul" //user id name of a test manager
issue.setCustomFieldValue(cf1, newvalue)
}
Your script is missing the acquisition/creation of the custom field manager object.
Try adding this after the imports
def customFieldManager = ComponentAccessor.getCustomFieldManager()
I suspect you're going to have problems with the setCustomFieldValue call as well - you are giving it a string, where it needs a user object.
Thanks Nic for your prompt feedback.
After adding the above import, I am not seeing the error which I posted before.
But while doing transition itself, I am getting the below error now::
Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see: http://confluence.atlassian.com/x/3McB java.lang.String cannot be cast to java.util.Collection
post successful transition only, I will able to check the set custom field value of i,e Test Managers as rrahul set successfully or not.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please re-read the last sentence of my answer. You may also need to do it as an array of users too, if the field is multi-user.
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.