I've got a rather complex post function that creates a bunch of tasks and subtasks when an Epic is created. In creating multiple issues, I have avoided having commas in the summaries of the issues for obvious reasons; being the delimiter, it creates another issue.
To avoid that, I've adjusted the summary text. In some places, I have replaced the comma with a forward slash. This looks to be a reserved character in JMWE.
Here is an example:
The task summary created by the Epic:
Notification of Equipment Purchase / altering or relocation
Checking for a match in the task workflow:
if issue.fields.summary.match(r/^Notification of Equipment Purchase // altering or relocation/i)
(I have to use the match method as the Summary is concatenated with the Epic Name)
I've tried both single quotes and double. If I don't use two forward slashes I can't even test it. So it doesn't find a match. I have similar issues with texts that include "and or" in them.
Any suggestions?
I'm not sure where exactly you're trying to escape characters. But generally, to avoid issues with commas and other special characters, the easiest is to use the "Iterator returns JSON" option of the Create Issue(s) post function. This way, you can use just about any character in string values.
Also, you mentioned "Checking for a match in the task workflow". Do you mean in a Build-your-own Condition or Validator? Or a Conditional Execution of a post function? Can you please elaborate?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure where you're using this Nunjucks template, but in any case, your problem is that you have a forward slash in a regular expression. The solution is to "escape" the forward slash using a backslash:
{% if issue.fields.summary.match(r/^'Notification of Equipment Purchase \/ altering or relocation'/i) and issue.fields.components | find({"name":"Transfer"}) != null %}
Also, I'm not sure why you added single quotes around the regular expression. Is the summary you're looking for something like:
'Notification of Equipment Purchase / altering or relocation'
with the quotes?
Also, why use the match method with a regular expression instead of just == ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That solved it! On the regular expression, each item in the iterator gets named with the Epic so by the time I'm evaluating it, the name is the task summary name + the Epic summary name. Since that changes each time they create an Epic, I needed to be able to dynamically match it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Appreciate the feedback. Not sure that selecting JSON is going to help. I get this error when trying to test the template for this line in the template window:
{% if issue.fields.summary.match(r/^'Notification of Equipment Purchase / altering or relocation'/i) and issue.fields.components | find({"name":"Transfer"}) != null %}
There was an error during the rendering of your template
(string) [Line 1, Column 74] parseSignature: expected comma after expression
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.