This article is for Timesheets for Data Center. Visit Cloud
Configuring External Drop-down Lists for Worklogs
Â
Configuring external drop-down lists for worklogs requires the Jira Administrator permission.
Third party add-ons may impact and/or break the functionality of your external drop-down lists.Â
You can add custom worklog fields (work attributes) to the Log Time dialog box. One type of custom worklog field is a drop-down list that retrieves list items from an external service. These externally sourced drop-down lists are called dynamic drop-downs. You define the list items in the external service, which connects to Tempo Timesheets.
Before you Begin
Learn about how JSONP works on the following IBM page:Â http://www.ibm.com/developerworks/library/wa-aj-jsonp1/
About this Task
 The following example shows how to create static queries for dynamic drop-downs. For more information on how to create dynamic queries by referencing other values, please see Cascading dynamic work attributes.Â
In the procedure below, the following example is used:
You want to add a custom worklog field called Operations to the Log Time dialog box so that users can choose an operation from a drop-down list. Tempo Timesheets sends a request to an external service to fetch the list of operations. A URL is included in the request. In Tempo Timesheets, in the Administration section, on the Work Attributes page, the URL that is specified for the external service is in the following form:
http(s)://www.acme.com/jsonp/operations
Tempo Timesheets automatically appends ?callback=?
to the URL when the request is sent to the external service. For example:
http(s)://www.acme.com/jsonp/operations?callback=?
At run-time, a callback parameter is generated (for example, fn
), and the JSONP library replaces the second question mark in the URL with the callback parameter.
Procedure
To configure an externally sourced drop-down list, set up the external service so that, when Tempo Timesheets sends the request, the external service returns a list of operations as a simple key-value list in the following JSONP (not JSON) code format:
Example: JSONP JavaScript with callback named "fn"
fn(
{"values":
[
{
"key":"",
"value":"Please select..."
},
{
"key":"0100",
"value":"This is option ONE"
},
{
"key":"0200",
"value":"And here is option TWO"
}
]
}
)
Function and variables
fn | In this example, the callback function name is 'fn'. The external service must use the callback parameter (see About this task above) as the callback function name. |
values | Variables that Tempo Timesheets understands. An array that is called 'values' must be returned and must contain objects with 'key'-'value' pairs. |
key | |
value |
Making the returned values depend on another selected value
You can set up the external service to return different items for the drop-down list depending on the following parameters:
The JIRA username of the user for whom time is logged. In this case, the URL in the request that Tempo Timesheets sends to the external service contains the JIRA username. For example:
http(s)://www.acme.com/jsonp/operations/taylor?callback=?
where
taylor
is the JIRA username of the person for whom time is logged.
   ÂThe issue that users log time to. In this case, the URL in the request that Tempo Timesheets sends to the external service contains the issue key. For example:
http(s)://www.acme.com/jsonp/operations/TO-21?callback=?
where
TO-21
is the key of the issue that the user logs time to.
  ÂThe item that is selected in a custom field on the issue. In this case, the URL in the request that Tempo Timesheets sends to the external service contains the key of the item that is selected in the custom field on the issue. For example, for the Account custom field on the issue, the URL contains the key of the selected account. For example:
http(s)://www.acme.com/jsonp/operations/201500?callback=?
where
201500
is the key of the selected account.
   ÂThe account that the user selects in the Account field (work attribute) on the Log Time dialog box. In this case, the URL in the request that Tempo Timesheets sends to the external service contains the key of the selected account. For example:
http(s)://www.acme.com/jsonp/operations/201501?callback=?
where
201501
is the key of the selected account.