---
title: "Link a Jira ticket based on the url custom field"
canonical: "https://support.appfire.com/space/SUPPORT/1235484783/Link%20a%20Jira%20ticket%20based%20on%20the%20url%20custom%20field"
format: markdown
---
## Description 

This documentation will show you how you can link a Jira work item based on the value of a URL custom field.

## \uD83D\uDCD8 Instructions

Please add the following snippet to the JQL expression in the [https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242225](https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/465242225) post function configuration.

```
{% set url_parts = issue.fields.customfield_xxxx.split('/') %}
issuekey = {{ url_parts[url_parts.length - 1] }}
```

> ℹ️ <u>**Explanation**</u>
> ℹ️ 
> ℹ️ - Replace `xxxx` with the ID of the URL custom field.
> ℹ️ 
> ℹ️ - The value of the URL field will be in the following format:
> ℹ️   - `https://YourInstaneName.atlassian.net/browse/<Jira issue Key>`
> ℹ️ - The expected value for the JQL expression is a valid Jira issue key e.g *ABC-123.*
> ℹ️ - `split('/')`
> ℹ️   - Splits the string contained in `customfield_xxxx` into an array of substrings based on the delimiter `'/'`.
> ℹ️   - The `split('/')` method would result in the array: `["https:", "", "YourInstaneName.atlassian.net", "ABC-123"]`.
> ℹ️ - `length - 1`
> ℹ️   - The `length` property of an array in Nunjucks returns the number of elements in the array. `length - 1` gives the index of the last element in the array e.g `ABC-123`.
> ℹ️ - `url_parts[url_parts.length - 1]`
> ℹ️   - This expression accesses the last element of the `url_parts` array.

## \uD83D\uDCCB Related articles



> Macro (contentbylabel)