I have used the clone functionality to clone a JIRA if a certain condition is met, however how do I set that a custom user select field is defaulted to a particular user only for the cloned JIRA.
Below is the current syntax
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// set Scrap field to Yes
def scrapCf = customFieldManager.getCustomFieldObjectByName("POD")
def fieldConfig = scrapCf.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).getOptionForValue("Transaction", null)
issue.setCustomFieldValue(scrapCf, option)
checkAttachment = {attachment -> false};
issue.assigneeId = null;
issue.summary = "[Reporting]-"+ transientVars["issue"].summary;
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
UserMessageUtil.success('Backreporting Ticket created.')
When i add, the below to it, it doesn't work:
def validatingUser = getFieldByName("Ticket Owner")
validatingUser.setFormValue("stanme")
Can anyone help?
Hello,
Your last lines are from the Behaviour functionality of ScriptRunner. You can not use it in post functions.
def ticketOwnerCf = customFieldManager.getCustomFieldObjectByName("Ticket Owner")
def stanNameCf = customFieldManager.getCustomFieldObjectByName("stanme")
issue.setCustomFieldValue(stanNameCf, issue.getCustomFieldValue(ticketOwnerCf))
Hi,
I replacing the last lines with your suggestion, however whilst the cloning still works, the field 'Ticket owner' was not defaulted to 'stanme'; it retained the original value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def ticketOwnerCf = customFieldManager.getCustomFieldObjectByName("Ticket Owner")
def stanNameCf = customFieldManager.getCustomFieldObjectByName("stanme")
issue.setCustomFieldValue(stanNameCf, issue.getCustomFieldValue(ticketOwnerCf))
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
and add import:
import com.atlassian.jira.event.type.EventDispatchOption
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry this is very strange - unless I'm missing something this should work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.event.type.EventDispatchOption
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// set Scrap field to Yes
def scrapCf = customFieldManager.getCustomFieldObjectByName("POD")
def fieldConfig = scrapCf.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).getOptionForValue("Transaction", null)
issue.setCustomFieldValue(scrapCf, option)
def ticketOwnerCf = customFieldManager.getCustomFieldObjectByName("Ticket Owner")
def stanNameCf = customFieldManager.getCustomFieldObjectByName("stanme")
issue.setCustomFieldValue(stanNameCf, issue.getCustomFieldValue(ticketOwnerCf))
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
checkAttachment = {attachment -> false};
issue.assigneeId = null;
issue.summary = "[Reporting]-"+ transientVars["issue"].summary;
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
UserMessageUtil.success('Backreporting Ticket created.')
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.