Removing tag with the workflow

Hello,
I'm using the workflow to add and remove tags on issues related to a particular one depending on the state of that particular issue.
That works great for me (root) the creator of all tags.
But for others (even if I give them all the rights) adding tags works but removing them does not.
All the tags are visibles and can be updated by everyone.
Is their something I am missing ?

Thanks in advance
11 comments
Comment actions Permalink
Hi Yann,
This should be working for other users as well. We need some more info to investigate the issue. What kind of WF rule are you referring to? Could I ask you to provide us with the entire workflow?

Regards,
  Alexander
0
Comment actions Permalink
Hi Yann,

please pay attention that it's needed to use tag reference (e.g. {tag: tagname}) but not tag name as parameter.

Look at the JT-18880 for details.
0
Comment actions Permalink
Hi Dmitry,
thanks for the lead, unfortunately it didn't worked after trials and errors I have the following code

rule toDeliverForLinked 
 
when hasTag("Livraison") { 
  if (State == {In Progress}) { 
    for each relates in relates to { 
      relates.addTag("En livraison"); 
      for each tag in tags { 
        if (tag.name == "A livrer" || tag.name == "Livré") { 
          tags.remove(tag); 
          break; 
        } 
      } 
      /* 
        relates.removeTag("{tag:A livrer}"); 
      */ 
      /* 
        relates.removeTag("{tag:Livré}"); 
      */ 
    } 
  } else if (State == {Fixed} || State == {Done}) { 
    for each relates in relates to { 
      relates.addTag("Livré"); 
      for each tag in tags { 
        if (tag.name == "A livrer" || tag.name == "En livraison") { 
          tags.remove(tag); 
          break; 
        } 
      } 
      /* 
        relates.removeTag("{tag:En livraison}"); 
        relates.removeTag("{tag:A livrer}"); 
      */ 
    } 
  } else { 
    for each relates in relates to { 
      relates.addTag("A livrer"); 
      for each tag in tags { 
        if (tag.name == "En livraison" || tag.name == "Livré") { 
          tags.remove(tag); 
          break; 
        } 
      } 
      /* 
        relates.removeTag("{tag:En livraison}"); 
        relates.removeTag("{tag:Livré}"); 
      */ 
    } 
  } 
}
prettyPrint();

and neither the
tags.remove(tag); 
prettyPrint();
nor the
relates.removeTag("{tag:Livré}"); 
prettyPrint();
works.
Looks like my issue is close to this one : http://youtrack.jetbrains.com/issue/JT-16275#

Regards
Yann
0
Comment actions Permalink
It better to compare tags on equality using "tag1_name".eq("tag2_name") method.

Also, relates.removeTag("{tag:Livré}"); definitely won't work, expected to use relates.removeTag({tag:Livré});, without quotes, as parameter, but it actually can don't work because of the mentioned bug JT-16275.

Try to use the alternative direct method tags.remove().
0
Comment actions Permalink
Hello,
so I changed my code to be:
rule toDeliverForLinked 
 
when hasTag("Livraison") { 
  if (State == {In Progress}) { 
    for each relates in relates to { 
      relates.addTag("En livraison"); 
      for each tag in tags { 
        var tag_name = tag.name; 
        if (tag_name.eq("A livrer", ignoreCase) || tag_name.eq("Livré", ignoreCase)) { 
          tags.remove(tag); 
          break; 
        } 
      } 
    } 
  } else if (State == {Fixed} || State == {Done}) { 
    for each relates in relates to { 
      relates.addTag("Livré"); 
      for each tag in tags { 
        var tag_name = tag.name; 
        if (tag_name.eq("En livraison", ignoreCase) || tag_name.eq("A livrer", ignoreCase)) { 
          tags.remove(tag); 
          break; 
        } 
      } 
    } 
  } else { 
    for each relates in relates to { 
      relates.addTag("A livrer"); 
      for each tag in tags { 
        var tag_name = tag.name; 
        if (tag_name.eq("En livraison", ignoreCase) || tag_name.eq("Livré", ignoreCase)) { 
          tags.remove(tag); 
          break; 
        } 
      } 
    } 
  } 
}
prettyPrint();
I have the same issue, can I do something similar without using the tags ?

Regards
Yann
0
Comment actions Permalink
Tag removing works fine on my environment.

Let's reduce the problem. So, please write the simple workflow to make sure that basically tags are removed:
rule tag removing 
 
when Priority.changed { 
  tags.remove({tag: 123}); 
}
prettyPrint();

If it works we have find the other incorrect code in the workflow.
0
Comment actions Permalink
Hello,
I created a new rule associated it to a project and created a new tag 123 available for everyone, when the rule is applied I have the following error :
Workflow optest reports error: Can't find method jetbrains.youtrack.workflow.wrappers.MutableIterableWrapper.remove(). (initialscript.js#122)

In the youtrack editor the rule does not validate I have the following No children in role "element" (declared cardinality is 1)

Screen Shot 2013-05-08 at 11.10.08 AM.png
0
Comment actions Permalink
What the Workflow Editor version are you using? Please update to the latest.
0
Comment actions Permalink
I had a version for mid february, I've downloaded the latest and reinstall it, now the editor validate the rule but not youtrack (we are using youtrack hosted on your servers) I have a message saying
the rule is not applicable for the project.

Screen Shot 2013-05-08 at 11.37.31 AM.png
0
Comment actions Permalink
Click on the error message - the dialog will show error details and possible quick fixes.
0
Comment actions Permalink
Hello,
I finally got it to work with the following
rule toDeliverForLinked 
 
when hasTag("Livraison") { 
  if (State == {In Progress}) { 
    for each relates in relates to { 
      relates.addTag("En livraison"); 
      relates.tags.remove({tag: Livré}); 
      relates.tags.remove({tag: A livrer}); 
    } 
  } else if (State == {Fixed} || State == {Done}) { 
    for each relates in relates to { 
      relates.addTag("Livré"); 
      relates.tags.remove({tag: En livraison}); 
      relates.tags.remove({tag: A livrer}); 
    } 
  } else { 
    for each relates in relates to { 
      relates.addTag("A livrer"); 
      relates.tags.remove({tag: En livraison}); 
      relates.tags.remove({tag: Livré}); 
    } 
  } 
}
prettyPrint();

I realized that when I switched from removeTag to remove I forgot the relates, stupid me.
Thanks for all.
Regards
Yann
0

Please sign in to leave a comment.