Hi,
when the issue is transitioned from one status to another then Field value in transition screen should be get clear.
we have Script Runner.
kindly help with script.
Thanks,
Abhishree Nagesh
If you want to clear assignee (which is not a custom field), try following on post function.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def issueManager = ComponentAccessor.getIssueManager()
issue.setAssignee(null)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
we are getting error please find the snapshot for error.
Kindly help.
Regards,
Abhishree Nagesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Abhishree Nagesh add following line anywhere before issueManager.updateIssue line
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By default jira would take previous value in transition screen(assignee).
But if user didnt change the value of assignee when they do the transition then ticket must automatically assign back to reporter.
How to achive this using script runner
kindly provide solution.
Regards,
Abhishree Nagesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this code which should fulfill your needs. I haven't tested it myself though. Let me know if it works.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def issueManager = ComponentAccessor.getIssueManager()
if(transientVars["issue"].assignee == issue.assignee){
issue.setAssignee(issue.reporter)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def cfm = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def changeHolder = new DefaultIssueChangeHolder()
def cf = cfm.getCustomFieldObject("customfield_XXXX") // CF ID
cf.updateValue(null, it, new ModifiedValue(null, ""), changeHolder)
issueManager.updateIssue(user, issueManager.getIssueObject(it.getKey()), EventDispatchOption.DO_NOT_DISPATCH, false)
@Abhishree Nagesh Try this one on script post function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Abhishree Nagesh ,
Please refer
Adaptavist has provide very good library for most of the scenarios.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Script is giving me error.
Actually the field is assignee field.
In every transition screen there is a assignee field. So assignee field value should get clear, when transition happens.(I.e in the transition screen field shoukld not take previous assignee name.)
Its giving me error in the last line. please find the snapshot of the error.
Kindly help.
Thanks,
Abhishree
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.