0

I want to clean the comments from youtrack by scheduler in a for Each loop with:

action: (ctx) => {
    var issue = ctx.issue;
    issue.comments.added.forEach(function(comment) {
   
    // https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
    comment.text = jQuery(comment.text).text();
      
    });
  },

But I get the error: jQuery is not defined.

How can I include jQuery in the script to use it to clean the comment from HTML tags.

1 Answers1

0

It is not possible to use jQuery inside of a workflow script. Still, you can create a helper function that does the trick:

function cleanComment(text) {
  return text.replace(/(<([^>]+)>)/gi, '')
}

and use it inside of the action part of the rule

skoch13
  • 94
  • 4
  • https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – Jk1 Mar 04 '22 at 09:03