Worfklow: Issue 'description' field is not updated

Hi guys,

I am trying to insert a specific description template (on issue creation) every time the user change the issue type.
However I do not want to delete the description field if it is not empty (i.e if user already fill it).

Here is my workflow: 

exports.rule = entities.Issue.onChange({
title: workflow.i18n('Insert bug template in description when creating related issue'),
guard: function(ctx) {
var issue = ctx.issue;
var becomesBug = (issue.fields.becomes(ctx.Type, ctx.Type.bug) || issue.fields.Type.name === ctx.Type.bug.name);
var isDescriptionEmpty = !issue.description || issue.description.length === 0;
return !issue.isReported && !issue.becomesReported && becomesBug && isDescriptionEmpty;
},
action: function(ctx) {
var issue = ctx.issue;
issue.description ="My template";
},
requirements : {
Type: {
type: entities.EnumField.fieldType,
name: "Type",
bug: { name: 'bug' }
}
}
});

The issue is: if the user fill the description, then clear it, then change the issue type -> the template is not inserted.

My concern is that the workflow receive the old  'description' state during the changing type transaction, ie the uncleared description.
Checking  manually 'use Markdown' updates the 'description' field and make it work.

Any idea or workaround?

I'm using  2017.4 Standalone version

Thanks!

 

3 comments
Comment actions Permalink

Hi Aricheton,

I have just tried to reproduce this issue and failed; it works for me.

May it be the case that the user doesn't clear the description field? E.g. some space or a new line is left?

I would recommend changing the emptiness check to (I've added `trim()` call):

 

    var isDescriptionEmpty = !issue.description || issue.description.trim().length === 0;

 

0
Comment actions Permalink

Hi, I have the similar issue, I use workflow to update issue description in version 2019.3 and when I change the type even though I have empty description and summary, description is not changed until I press F5. I suspect that the render method is not called correctly. What can I do? The problem is not in guard because when I console.log() description, it is empty. Workflow is below

 

var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.onChange({
title: workflow.i18n('Insert default description template for external users'),
guard: function(ctx) {
var issue = ctx.issue;
return !issue.isReported && !issue.becomesReported && issue.description === null;
},
action: function(ctx) {
if (ctx.issue.fields.Type.name === ctx.Type.Bug.name) {
ctx.issue.description =
workflow.i18n("**Shrnutí problému:**") +
"\n\n" +
workflow.i18n("**Operační systém, prohlížeč a jeho verze:**") +
"\n\n" +
workflow.i18n("**Datum a čas výskytu:**") +
"\n\n" +
workflow.i18n("**Účet (RUS):**") +
"\n\n" +
workflow.i18n("**Link na stránku s problémem:**") +
"\n\n" +
workflow.i18n("**Popis vzniku problému:**") +
"\n\n" +
workflow.i18n("**Screenshoty reprodukce problému:**") +
"\n\n" +
workflow.i18n("**Dolňkové informace (seznam ID zón, ID reklamy, XHR request, SQL dotaz, clickURL, impURL, apod.):**") +
"\n\n" +
workflow.i18n("**Proč se jedná o problém:**") +
"\n\n" +
workflow.i18n("**Očekávaný výsledek:**") +
"\n\n" +
workflow.i18n("**Související ticket:**") +
"\n\n";
}
},
requirements: {
Type: {
type: entities.EnumField.fieldType,
Bug: {}
}
}
});
0
Comment actions Permalink

Hello,

Thank you for your comment. This is a known issue. We are investigating it in the context of the https://youtrack.jetbrains.com/issue/JT-55466 report. Please feel free to Watch this issue to receive the updates.

Should you have any further questions, feel free to contact us.

 
0

Please sign in to leave a comment.