I want to detect the conflict of the existing tickets having Same date and time ie; (date and time field) while creating a new ticket that can able thrown an error when same date and time is selected.
This enhancement project will be to determine the best method for using some scheduling conflict detection logic in the project.
Problem: Today, when users create a new ticket in the issuetype of project, there is nothing that will determine whether or not the new tickets will conflict with an existing tickets that may have already been scheduled status.
Conflict Detection Logic:
POD (Multiple Select) ------> Custom field
POD Conflict Detection: If the ticket being created has the same POD# as a change already on the calendar the user should get a Yellow Pop-UP that states, “A change on this POD already exists on the calendar for this date & time. Please ensure your change does not conflict with existing change before submitting your ticket.”
DataCenter(Multiple Select) -------> Custom Field
DataCenter Conflict Detection: If the ticket being created has the same DataCenter(s) as a change already on the calendar the user should get a Yellow Pop-UP that states, “A change on this Datacenter(s) already exists on the calendar for this date & time. Please ensure your change does not conflict with existing change before submitting your ticket.”
Service Provider-----> Custom field
Service Provider Conflict Detection: If the ticket being created has the same Service Provider(s) as a change already on the calendar the user should get a Yellow Pop-UP that states, “A change for this Service Provider(s) already exists on the calendar for this date & time. Please ensure your change does not conflict with existing change before submitting your ticket.”
Multiple Conflict Detection: If two or more of these conditions are met the user should get a Red Pop-Up Warning that states, “Two or more conflicts detected (POD, DC, Service Provider) with an existing change. Please ensure your change does not conflict with existing change before submitting your ICC ticket.”
A user should not be denied the ability to create a change based on this logic, but simply receive a warning that their change may be in conflict with a previously scheduled change.
Hi @Imran Khan
This can be achieved by using ScriptRunner for Jira. On server you can use the Behaviours that will and can show messages on the create issue screen but a Workflow validator can also be used to have a bit more proper restriction. Since you want use to be able to create the issues then using behaviour can be used to display some message to the user.
I hope it helps.
Ravi
Hi Ravi Sagar,
Thanks for your quick response, I'm using below script which throws the error but the problem is when date and time it is not considering particular time frame, it is considering the whole day for example if a ticket is created with 16 March with time 5:30pm, and when i start to create a new ticket with that date 16March it is throwing error, i need to want to through error when the same date and time is selected, Is that can be achived?
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query
def artefactId = getFieldByName("POD (Multiple Select)")
def artefactIdValue = artefactId.getValue() as String
artefactIdValue = artefactIdValue.replaceAll("[\\[\\]]","\"")
artefactIdValue = artefactIdValue.replaceAll(", ","\", \"")
def artefactId1 = getFieldByName("Start Date & Time")
def artefactIdValue1 = artefactId.getValue() as String
artefactIdValue = artefactIdValue.replaceAll("[\\[\\]]","\"")
artefactIdValue = artefactIdValue.replaceAll(", ","\", \"")
String projectKey = null
def projectObj = underlyingIssue?.getProjectObject()
if (projectObj) {
projectKey = projectObj.key
} else {
projectObj = getIssueContext().getProjectObject()
projectKey = projectObj?.getKey()
}
def jql = "project = \"${projectKey}\" AND \"POD (Multiple Select)\" in (${artefactIdValue}) AND \"Start Date & Time\" >= 1d AND status in (Scheduled) AND status not in (Closed)"
int jqlIssues = getIssuesFromJQL(jql)
//artefactId.setHelpText(jql)
if(jqlIssues > 0){
artefactId.setHelpText("<a style=\"color:gold;\">POD has a Confliction</a> ${jqlIssues}")
}
else{
artefactId.setHelpText("")
}
int getIssuesFromJQL(String jqlQuery) {
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
JqlQueryParser jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
Query query = jqlQueryParser.parseQuery(jqlQuery)
def count = searchService.searchCountOverrideSecurity(user, query)
//SearchResults searchResults = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
//List<MutableIssue> mutableIssueList = searchResults.getIssues().collect { issue -> issueManager.getIssueObject(issue.getId()) }
return count
}
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.