Close Helpdesk ticket with related issue in project

I copied a ticket from Helpdesk into an issue tracker project. Is there a way to automatically close the corresponding Helpdesk ticket when the ticket in the issue tracker is closed?

0
1 comment

Hello!
Stan from YouTrack Support here. 

When you use the workflow to copy a helpdesk issue to a standard tracker project, the helpdesk issue and the newly-created issue become linked

You can create a workflow that would close the related helpdesk issue when the tracker issue is closed. I've put together a workflow that checks specifically for the ‘Fixed’ status being applied to the tracker issue and applies the same status to the helpdesk issue. You can use this workflow as a jumping off point to adjust it to your use case. Please see our documentation for workflows at https://www.jetbrains.com/help/youtrack/devportal/Workflows-in-JavaScript.html 

const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
  title: 'Close Helpdesk ticket when linked issue is fixed',
  guard: (ctx) => {
    return ctx.issue.fields.isChanged(ctx.State) && 
           ctx.issue.fields.State.name === 'Fixed';
  },
  action: (ctx) => {
    ctx.issue.links['relates to'].forEach(linkedIssue => {
      if (linkedIssue.project.projectType.typeName === 'Helpdesk' && 
          linkedIssue.fields.State.name !== 'Fixed') {
        
        const fixedState = linkedIssue.project.findFieldByName('State').findValueByName('Fixed');
        if (fixedState) {
          linkedIssue.fields.State = fixedState;
        }
      }
    });
  },
  requirements: {
    State: {
      type: entities.State.fieldType
    },
    Relates: {
      type: entities.IssueLinkPrototype,
      outward: 'relates to'
    }
  }
});

Don't hesitate to reach out anytime if you have any questions. Have a nice day! 

0

Please sign in to leave a comment.