I have a custom field of type project picker and i want to get the value selected, here my code
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.project.Project
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11001");// ID of my custom field.
def value = (String)issue.getCustomFieldValue(customField);
log.info("the project selected is"+value)
and i get an error : the variable issue is undeclared
any help !!
Hi Damon,
What version of SR are you on? You might try this instead:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.onresolve.scriptrunner.canned.jira.utils.ConditionUtils
import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue
def issue = ComponentAccessor.getComponent(IssueManager).getIssueByKeyIgnoreCase("SRC-1")
def clonesId = ComponentAccessor.getComponent(IssueLinkTypeManager).getIssueLinkTypes().findByName("Cloners")?.id
def cloneIssue = new CloneIssue()
def additionalCode = """
issue.setSummary("CLONED: " + issue.getSummary())
checkLink = {link -> link.issueLinkType.name != "Cloners"}
"""
Map<String, Object> inputs = [
issue : issue,
(ConditionUtils.FIELD_ADDITIONAL_SCRIPT): [additionalCode, ""],
(CloneIssue.FIELD_COPY_COMMENTS) : true,
(CloneIssue.FIELD_TARGET_PROJECT) : "DEST",
(CloneIssue.FIELD_LINK_TYPE) : clonesId + " inward",
(CloneIssue.FIELD_SELECTED_FIELDS) : null, //clone all the fields
] as Map<String, Object>
def errorCollection = cloneIssue.doValidate(inputs, false)
if (errorCollection.hasAnyErrors()) {
log.warn("Couldn't clone issue: ${errorCollection}")
}
else {
cloneIssue.doScript(inputs)
}
Adaptavist ScriptRunner for JIRA 5.4.12
Yes, that did the trick! Thank you!
How did you know that, btw? Is there documentation that would have told me that the interface seems to have changed at some point?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Damon,
That's a good question. I took a quick look at our documentation and I don't see an example of CloneIssue being used manually, so I don't think you would have known about any changes. I can see how that would be frustrating!
The problem here, in my opinion, is that running CloneIssue manually is something we don't particularly want everyone to do, so it's not likely to end up in the documentation. It can be difficult to use and often creates more problems for users than it solves, since the built-in clone script is often "good enough." Only in niche cases do we recommend doing it, such as in your situation.
In any case, if you run into a problem like this again, I'd suggest submitting a support request through our Service Desk portal here: https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=server&tab=support
Regards,
Josh
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.
Hi Joshua Yamdogo @ Adaptavist ,
is there a full documentation out there in the internetz about the possible map values of the CloneIssue params?
CloneIssue.FIELD_COPY_COMMENTS
CloneIssue.*WHAT CAN I DO HERE ¯\_(ツ)_/¯ *
Thanks for your time,
cheers
slothy
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.