Good day! Is it possible to link the release date to the "end date" of the tasks that it includes. For example, change the release date and automatically change the "end date" tasks that are included in this release.
Hi,
Sorry for late respons @Ксения and my bad in script. I forgot the get current issue from current event. Can you please change the following code with the warning.
MutableIssue currentIssue = (MutableIssue) event.issue
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
now it working, but with result "null".
@Ксения, check please.
This script working after any task update, correct?
Only for task from project "Cистема электронного документооборота"
Sorry for stupid question, we newer use scripts before.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
No problem @Andrey Ozerov :) Yes it works when issue updated event fired in project "Cистема электронного документооборота".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andrey Ozerov@Orkun GedikIt's not working :(
Changed the release date, end date has not changed in the task.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please make sure the field names and ids in the script. Also, can you check your jira logs please and let me know if there is a error about script. @Ксения
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.
@Orkun Gedik, hello!
Tell me please, what exactly is in those quotation marks to write? Now there is "insert the name of the desired field».
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ксения,
Yes it is possible. You can use a listener to update your customfields based on another changes on another customfield. If you have Script Runner plugin in your Jira, let me know if you need help for implementing your listener.
Orkun Gedik
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome @Ксения.
You can use Script Listener with IssueUpdated event. I wrote a script for you. Let me know if you have a question and don't forget to update the names and ids of your customfields in script.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
MutableIssue currentIssue = (MutableIssue)issue
ApplicationUser currentuser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def releaseChange = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Release CF Date Name Here"}
def endChange = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "End Date CF Name Here"}
if(releaseChange || endChange) {
CustomField endDateCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("endDateId")
CustomField releaseDateCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("releaseDateId")
if (releaseChange) {
currentIssue.setCustomFieldValue(endDateCF, releaseDateCF.getValue(currentIssue))
} else if (endChange) {
currentIssue.setCustomFieldValue(releaseDateCF, endDateCF.getValue(currentIssue))
}
ComponentAccessor.getIssueManager().updateIssue(currentuser, currentIssue, 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ксения,
Is it Script Console? Because you cannot get the current issue with "issue" paramater in Script Console. You should place this script in a listener
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.
@Orkun Gedik, hello!
Tell me please, what exactly is in those quotation marks to write? Now there is "insert the name of the desired field».
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.
import com.atlassian.jira.event.project.VersionUpdatedEvent
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def event = event as VersionUpdatedEvent
def version = event.version
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getUserManager().getUserByName("jira.bot")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectByName('End date')
def searchService = ComponentAccessor.getComponent(SearchService)
def queryParser = ComponentAccessor.getComponent(JqlQueryParser)
def query = queryParser.parseQuery("project = JRA and resolution is empty")
def search = searchService.search(user, query, new PagerFilter())
search.results.each {documentIssue ->
log.debug(documentIssue.key)
MutableIssue issue = issueManager.getIssueObject(documentIssue.id)
cField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cField), version.getReleaseDate()), new DefaultIssueChangeHolder())
}
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.