Booking System

Create booking requests and booking workflows in order to avoid Environment usage conflicts.


You have defined your Environments and you would like people to book your Environments for different kind of activities like UAT, demos, technical maintenance, etc.


Your Environments are already defined in Apwide Golive. Not yet? Follow our Quick setup

Basic Use Case

For this use case, we are relying on Jira core features: Jira issue types, Custom Fields, Workflows, etc.

1. Create a new Jira Issue Type to support your Environment Booking requests

For instance, you can name it “Booking Request”. Associate your newly created Issue Type with an existing Jira Project, or create a new Jira Project to be used for your Booking Requests (it’s up to you).

2. Create 3 Jira Custom Fields (or reuse existing ones)

  • Custom Field of type “Environment” to store the Environments linked to your Booking Requests. You can name it “Environment(s) to book”

  • Custom Field of type “Date Time Picker” to store the beginning of your Booking Requests. You can name it “Start time”.

  • Custom Field of type “Date Time Picker” to store the end of your Booking Requests. You can name it “End time”.

Create custom fields for your Booking Request

Related Jira Server/DC documentation How to add a custom field?

3. Create a Screen for your Booking Request Issue Type

Add the fields you defined in STEP 2 in your new screen. It should look like this:

Configure a new screen for your Booking Request

Related Jira Server/DC documentation How to create and activate a screen?

4. Create a workflow for your Booking Request Issue Type

The workflow is really up to you, you can add as many steps and approvals as you need. Here is an example of very simple workflow:

Create a workflow for your Booking Request

Related Jira Server/DC documentation How to create and activate a workflow?

5. Test your Booking Request

From your Jira Project, create a new Booking Request and make sure it works. Adjust if needed.

Test your Booking Request

6. Create a Booking Requests Calendar

Create a new Golive Timeline (more info: Timelines) Add a new Issue Calendar by typing “Booking Request” (or the name you choose for your Issue Type):

By default, all Calendar information should be there. Double-check the fields mapping to make sure they are the Custom Fields you have created before.

Create your Booking Request Calendar

After clicking on “Done”, you should see the Booking Requests on your Timeline, with their statuses.

Your Booking Request system is ready!


Congrats! Now you have a Calendar displaying your Booking Requests and their statuses.

You can reschedule your Booking Requests on the Timeline with drag-and-drop: the “Start time” and “End time” will be updated and the requester will be notified by Jira.

You can also move the Booking Requests from one Environment Swimlane to another in order to update the Environments booked by the request. Notification will also be sent to the requester.

Advanced: Conflict Management

Go further and list potential booking conflicts in your Booking Request using ScriptRunner Jira App.

Display potential conflicts in your Booking Requests

1. Add a new Script

After installing the ScriptRunner Jira App, add our script in the Script Editor (code reference below).

New Script in the Script Editor section (check below for the code)

2. Add a new Behaviour

Then, create a new Behaviour and map it with your Booking Request project and issue type.

New entry in the Behaviour section

3. Call the Script from your Behaviour

In your Behaviour, define your Environment and Start/End fields as "Required" and add Server-side scripts for each of them (code reference below). All Server-side scripts should be identical as they will trigger the same ConflictChecker script.

Server-side Script (check below for code) for Environment and Start/End dates fields

Script Parameters:

  • issueTypeName: your Booking Request issue type name

  • startDateFieldName: your booking start date/time field name

  • endDateFieldName: your booking end date/time custom field name

  • environmentFieldName: your Environment custom field name

  • helpFieldName: the name of the field under which the warning message should appear (if not defined, it will be your endDateFieldName)

  • timelineUrl: URL used in the warning message button

  • dateFormat: date format used for the period (if not defined, it will be your Jira date format)

Code Reference

Server-side Script (Behaviour)
ConflictChecker (Script Editor)
Server-side Script (Behaviour)
import com.apwide.behaviour.ConflictChecker
import org.apache.log4j.Level
new ConflictChecker(
ctx: this,
issueTypeName: "Booking Request",
startDateFieldName: "Start time",
endDateFieldName: "End time",
environmentFieldName: "Environment(s) to book",
helpFieldName: "Start time",
timelineUrl: "/secure/ApwideGolive.jspa#/home/timeline?view=timeline197",
dateFormat: "MMM d",
logLevel: Level.DEBUG
ConflictChecker (Script Editor)
package com.apwide.behaviour
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.entity.WithKey
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.jql.parser.DefaultJqlQueryParser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.context.IssueContext
import groovy.util.logging.Log4j
import org.apache.log4j.Level
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
import static
class ConflictChecker {
static final String JIRA_JQL_DATE_FORMAT = 'yyyy-MM-dd HH:mm'
def ctx
String dateFormat
String issueTypeName
String startDateFieldName
String endDateFieldName
String environmentFieldName
String timelineUrl
String helpFieldName
Level logLevel
void check() {
log.setLevel(logLevel ?: Level.INFO)
Date startFieldValue = getDateValue(startDateFieldName)
Date endFieldValue = getDateValue(endDateFieldName)
List environmentFieldValue = getEnvironmentsValue(environmentFieldName)
if (!startFieldValue || !endFieldValue || !environmentFieldValue) {
log.debug("No values found")
// JQL query
List<Issue> conflicts = searchForConflicts(startFieldValue, endFieldValue, environmentFieldValue)
if (conflicts.isEmpty()) {
log.debug("No conflicts found")
log.debug("Found ${conflicts.size()} conflicts")
def warningMessage = """
<div class="aui-message aui-message-warning">
<p>There are conflicting Booking Requests:</p>
<table style="margin: 15px 0px; width:100%">
<a target="_blank" href="${timelineUrl}" class="aui-button">
<span class="aui-icon aui-icon-small aui-iconfont-search"></span>&nbsp;Open the Timeline
private String renderConflictList(List<Issue> conflicts) {
CustomField startCustomField = getCustomFieldByName(startDateFieldName)
CustomField endCustomField = getCustomFieldByName(endDateFieldName)
CustomField environmentCustomField = getCustomFieldByName(environmentFieldName)
return conflicts.collect {issue ->
Date startDate = (Date) issue.getCustomFieldValue(startCustomField)
Date endDate = (Date) issue.getCustomFieldValue(endCustomField)
List environments = (List) issue.getCustomFieldValue(environmentCustomField)
return """
<td><a target="_blank" href="${baseUrl()}/browse/${issue.key}">${issue.key}</a></td>
<td>${displayedDate(startDate)} - ${displayedDate(endDate)}</td>
private void writeHelpText(String helpText) {
FormField endField = ctx.getFieldByName(helpFieldName ?: endDateFieldName)
private List<Issue> searchForConflicts(Date startFieldValue, Date endFieldValue, List environmentFieldValue) {
Query query = toQuery(startFieldValue, endFieldValue, environmentFieldValue)
PagerFilter pager = PagerFilter.newPageAlignedFilter(0,50)
SearchResults<Issue> results = searchService().searchOverrideSecurity(loggedInUser(), query, pager)
log.debug("Found ${results.getTotal()} issues corresponding to search")
IssueContext issueContext = ctx.getIssueContext()
if (issueContext instanceof WithKey) {
String issueKey = ((WithKey)issueContext).getKey()
log.debug("Issue context with key ${issueKey}")
return results.getResults().findAll { !it.key.equals(issueKey) }
} else {
log.debug("Issue context without key")
return results.getResults()
private Query toQuery(Date startFieldValue, Date endFieldValue, List environmentFieldValue) {
String environmentFieldValueString = environmentFieldValue.join(",")
String stringQuery = """
type = "${issueTypeName}"
AND "${startDateFieldName}" < "${jqlDate(endFieldValue)}"
AND "${endDateFieldName}" > "${jqlDate(startFieldValue)}"
AND "${environmentFieldName}" in (${environmentFieldValueString})
log.debug("query is: ${stringQuery}")
return new DefaultJqlQueryParser().parseQuery(stringQuery)
private Date getDateValue(String fieldName) {
try {
FormField dateField = ctx.getFieldByName(fieldName)
return dateField ? (Date) dateField.getValue() : null
} catch (GroovyCastException ex) {
return null
private List getEnvironmentsValue(String fieldName) {
try {
FormField environmentField = ctx.getFieldByName(fieldName)
return environmentField ? (List) environmentField.getValue() : null
} catch (GroovyCastException ex) {
return null
private String displayedDate(Date date) {
return date.format(displayDateFormat())
private String displayedEnvironments(List environments) {
return environments ? environments.collect{ }.join("<br />") : "-"
private String displayDateFormat() {
def format = dateFormat != null ? dateFormat : ComponentAccessor.getApplicationProperties().getString(JIRA_DATE_TIME_PICKER_JAVA_FORMAT)
log.debug("date format to be used will '${format}'")
return format
private String jqlDate(Date date) {
return date.format(JIRA_JQL_DATE_FORMAT)
private String baseUrl() {
return ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
private CustomField getCustomFieldByName(String name) {
return ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(name)
private SearchService searchService() {
return ComponentAccessor.getComponent(SearchService.class)
private ApplicationUser loggedInUser() {
return ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


Jira is very powerful for its workflows, that’s why we have decided to rely on it for our Booking System, instead of implementing our own system. The setup may be a little complex for Jira beginners, that’s why we offer free assistance for this configuration.

If you need our help, contact us.