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.
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.
@Orkun GedikAre you here?
Thank you, Gedik!
Yes, Script Runner is. Please tell me how the query should look like to make the end date task equal to the release date?
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.ComponentAccessorimport com.atlassian.jira.event.type.EventDispatchOptionimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.user.ApplicationUserMutableIssue currentIssue = (MutableIssue)issueApplicationUser 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)}
Hello, Gedik.
Help me, please
What should I do in line 7?
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
now it working, but with result "null".
@Ксения, check please.
@Orkun Gedik
This script working after any task update, correct?
Only for task from project "Cистема электронного документооборота"
Sorry for stupid question, we newer use scripts before.
No problem @Andrey Ozerov Yes it works when issue updated event fired in project "Cистема электронного документооборота".
@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».
@Orkun GedikAre you here?)
import com.atlassian.jira.event.project.VersionUpdatedEventimport com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.jql.parser.JqlQueryParserimport com.atlassian.jira.web.bean.PagerFilterimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.ModifiedValueimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def event = event as VersionUpdatedEventdef 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())}
It looks like you're new here. Sign in or register to get started.