Removing company signature from incoming Help Desk tickets
Hello:
I'm looking for some guidance as to how to properly remove our company signature from being shown on our Help Desk as it takes up a lot of space. There is another post on this subject that goes over my head. Specifically, I'd like to remove the portion of text that begins with "800" and ends in "Reserved."
From what I understand per the other post, I need to tag the post in the mailbox integration field of "Last Message Related Email" to a custom tag, then use the workflow editor to process a workflow using that tag. My JS is rather limited so I don't have much confidence that I'm coding it correctly. Variable signature here is a sample signature.
var entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
title: 'cleanup signature for emails',
guard: function(ctx) {
return ctx.issue.becomesReported;
},
action: function(ctx) {
var issue = ctx.issue;
let signature = "Company Signature Here";
if (issue.description.toLowerCase().includes(signature)) {
issue.tags.forEach(function(tag) {
if (tag.name === 'signaturecleanup') {
ctx.issue.description.replace(signature, '');
}
});
}
issue.tags.forEach(function(tag) {
if (tag.name === 'signaturecleanup') {
issue.applyCommand('remove tag signaturecleanup', ctx.currentUser);
}
});
},
requirements: {
State: {
type: entities.State.fieldType,
Open: {
name: "Submitted"
}
},
}
});
Any clarity and guidance here is greatly appreciated. Many thanks.
Please sign in to leave a comment.
Hi! Email signatures are supposed to be cut out of the ticket description by the mailbox integration, but it is possible that it failed to do so in your particular case. If you are using the latest YT version (2023.1) and the signature was preserved in the ticket created out of an email, we would appreciate it if you could share an .eml file of that email via our upload service and let us know the upload ID–we'll use that to improve the email processing logic.
Using a workflow here is the right solution in general to provide for such cases, but there are some things I'd like to point out.
First, Last Message Related Emails referred to a custom field that was a part of the previous workflow-based helpdesk approach that has now been deprecated in favor of new helpdesk projects. In 2023.1, the Post-processing section of mailbox integration contains these fields: Command for new issues and tickets and Command for new comments. You can specify the command that you need applied to tickets or comments there. You can use the tag solution (tagging is done via a command here), or you could create an action workflow rule with the custom command name (e.g., delete-signature) and use that command name to apply the action directly, without the tag in between.
Second, you could specify the condition more clearly in the guard function, e.g., so that the workflow is only ever executed when the reported ticket does have a description (and that description contains the signature):
Third, the replace() method doesn't actually replace any content in the existing string, but creates a new string where the string or its part is replaced. So something like this should work:
Finally, just a small remark that if you plan on using the requirement regarding the State field, it might be a little confusing if the Submitted value is to be referred to as Open. But that's up to you, of course.