Apply rule when a comment is created

Hi, i want to apply a rule when a new comment is being created, in the jetbrain knowledge base i found entity "issueComment", but my code doesn't work, i think something is wrong in my guard condition, also i don't know if i should add something to requirements

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

exports.rule = entities.Issue.onChange({
title: 'module',
  guard: (ctx) => {
    return ctx.issueComment.created ;
  },

The console log: 

Processing issue DEV-11:
TypeError: Cannot read property 'created' of undefined
2 comments
Comment actions Permalink

Hello Seth,

Try using the following guard:

 guard: (ctx) => { return ctx.issue.comments.added.isNotEmpty(); },

You may find an example of the workflow rule that uses this guard here.

0
Comment actions Permalink

Thanks for the answer! 

0

Please sign in to leave a comment.