---
schema: rendered-html/v1
title: "Custom Scripts | Developer Portal for YouTrack and Hub Documentation"
source_url: https://www.jetbrains.com/help/youtrack/devportal/custom-scripts.html
generated_at: 2026-06-11T15:02:21.213822+00:00
---

Feedback

Thanks for your feedback!

Was this page helpful?

YesNo

Developer Portal for YouTrack and Hub

- Developer Portal
- Apps
- MCP Tools
- YouTrack Workflows
- JavaScript Workflow Quick Start Guide
- Create a Workflow
- Edit a Workflow
- Workflow Rule Types
- On-change Rules
- On-schedule Rules
- State-machine Rules
- Action Rules
- SLA Rules
- [Custom Scripts](custom-scripts.html)
- Transactions
- Use Cases for Workflows
- Web-based Workflow Editor
- Using an External Code Editor
- Default Workflows
- Custom Workflow Repository
- JavaScript Workflow Reference
- YouTrack Import Scripts
- YouTrack Form API
- YouTrack REST API
- Hub REST API

1. YouTrack Workflows
2. Workflow Rule Types
3. [Custom Scripts](#0)

# Custom Scripts﻿

Last modified: 07 May 2026

Custom scripts let you organize and reuse blocks of code. They don't contain any specific type of rule. Instead, they contain code that can be used in other scripts.

> ### note
>
> Availability
>
> The ability to create and edit custom scripts is only supported by the JavaScript Editor. This feature is not available for the Workflow Constructor.

In any script, you can define whichever objects and functions you want to use in other scripts by assigning them as properties of the `exports` object.

Here's an example.

First, we'll create a custom script that defines a simple function.

```
// 'math.js'

exports.f = function (x) {
  return x * x - 6 * x + 13;
};

// And these are a couple of constants we need.
exports.lower = 0;
exports.upper = 9;
```

Now you have a `math` object that contains the properties that you defined for the `exports` object. This means that you can access this function as `math.f`.

Next, we'll write an action rule that references this function.

```
// 'chart.js'

const entities = require('@jetbrains/youtrack-scripting-api/entities');

const math = require('./math');

exports.rule = entities.Issue.action({
  title: 'Draw a chart',
  command: 'draw',
  action: (ctx) => {
    const issue = ctx.issue;
    var chart = '';
    for (var x = math.lower; x <= math.upper; x++) {
      var fx = math.f(x);
      var line = x + ' | ';
      for (var i = 0; i < fx; i++) {
        line = line + "#";
      }
      chart = chart + line + "\n";
    }
    issue.addComment(chart);
  }
});
```

SLA RulesTransactions

- Privacy & Security
- Terms Of Use
- Trademarks
- Legal

Copyright © 2000–2026 JetBrains s.r.o.
