Developer Portal for YouTrack and Hub Help

Process Spam

This workflow is used to manage spam in a helpdesk project.

Name

@jetbrains/youtrack-workflow-spam

Auto-attached

no

Rules

  • Close a ticket when tagged as spam (on-change)

  • Remove spam after 30 days (on-schedule)

Use Case

When a helpdesk agent encounters an unsolicited message that is irrelevant or inappropriate for the support team to handle, they can mark it as spam. This is done using the Mark as spam option in the action menu or by adding the spam tag to the ticket. This action triggers the on-change rule that adds the spam tag (if it hasn't been added already) and closes the ticket as Solved.

Once a ticket has been marked as spam, it is removed from the system after 30 days of inactivity.

Modules

This workflow is used to manage spam in a helpdesk project. It supports the rules described below.

Close a ticket when tagged as spam

When a ticket is updated, this on-change rule checks whether it has been flagged using the spam tag. If a tag named spam doesn't already exist, the corresponding tag is created with the root user as its owner.

If the ticket has been flagged as spam, the workflow changes the value for the State field to Solved.

This workflow supports the Mark as spam option for processing tickets in helpdesk projects To learn more about this functionality, see https://www.jetbrains.com/help/youtrack/server/marking-tickets-as-spam.html.

const entities = require('@jetbrains/youtrack-scripting-api/entities'); exports.rule = entities.Issue.onChange({ title: 'Close a ticket when tagged as spam', guard: (ctx) => { return ctx.issue.tags.added.find(it => it.name === "spam" && it.owner.login === "root"); }, action: (ctx) => { ctx.issue.fields.State = ctx.State.Solved; }, requirements: { State: { type: entities.State.fieldType, Solved: {} } } });

Remove Spam After 30 Days

This on-schedule rule checks all tickets (and issues) at 12:00 AM and automatically deletes any ticket that has been marked with the spam tag and has not been updated in the last 30 days.

var entities = require('@jetbrains/youtrack-scripting-api/entities'); exports.rule = entities.Issue.onSchedule({ title: "Remove spam after 30 days", cron: '0 0 0 * * ?', search: 'tag: spam updated: * .. {minus 30d}', guard: function(ctx) { return ctx.issue.tags.find(it => it.name === "spam" && it.owner.login === "root"); }, action: function(ctx) { ctx.issue.applyCommand("delete"); } });
Last modified: 7 November 2024