Services of “Issue Reminders” app can be accessed by Script Runner and other plugins. You can browse Issue Reminders JavaDoc for available services. You can use this feature to create automatic reminders when status of an issue is changed.
Following Script Adds script adds a new Reminder to Current Issue. You can use it to create a reminder after a workflow transitionfor assignee of the issue. Reminder is scheduled after 3 days when the issue is transitioned.
Code Block | ||
---|---|---|
| ||
import java.time.*; import java.time.temporal.ChronoUnit; import java.util.Date; import com.atlassian.jira.component.ComponentAccessor import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.deniz.jira.reminders.service.ReminderService; import com.deniz.jira.reminders.data.*; import com.atlassian.jira.component.ComponentAccessor def project = issue.getProjectObject() // Specify that classes from this plugin should be available to this script @WithPlugin("com.deniz.jira.reminders") // Inject plugin module @PluginModule ReminderService reminderService; def user = reminderService.getApplicationUser("admin"); def ReminderImp reminder = new ReminderImp(); reminder.setSummary("This is reminder summary")summary = "the time has come"; reminder.setLongDescription("This is *reminder* description")longDescription = "Issue reached reminder-date!"; reminder.setIssueId(issue.getId()issueId = issue.id; Instant inst = Instant.now().plus(3,ChronoUnit.DAYS); reminder.setOwnerUserKey(user.getKey())reminderDate = Date.from(inst); def target = new ReminderTargetImp(); target.setIdentifier(user.getKey())identifier = issue.assignee.key; target.setTargetType(targetType = ReminderTarget.ReminderTargetType.USER); reminder.addReminderTarget(target); reminderService.addReminder(reminder); |