Question about JIRA Workflow Toolbox - setting fields after workflow transition

Issue #604 resolved
David Kaplan created an issue

Ok, thanks I tried the a(^$)toString(count(subtasks())) as part of the post function for setting fields based on other fields and that passed the syntax checking but when I tried it in the issue workflow, with performing the transition, no field setting happened.

thanks, David


Of course you can. If you are trying to set a Text field, you have to use the following setting rule: a(^$)toString(count(subtasks()))

If you are trying to set a Number field, you can use any of these:

(^$)count(subtasks()) a(^$)count(subtasks())

Prefix 'a' means that the value part of the setting rule will be evaluated in advanced parsing mode. When we use a numeric or date-time field as target, the post-function tries to evaluate it as a formula automatically, thus why you don't need to use prefix 'a' in that case.

Please, let me know if you have any other question.

David, if you don't mind, I would prefer to receive these kind of questions as issues at http://support.workflowarts.com. It's easier to track than emails, and your question and my answer will be helpful to other users of the plugin.

Best regards,

Fidel

El 11/5/17 a las 22:18, Kaplan, David escribió: Hi Fidel, Thank you for responding

At first I was just trying a custom field with text type. I added it to a screen of the issue type and wanted to see upon transitioning to a certain status, whether the value would get set. If I put a constant in, like 5….I could see the field changing when I performed the status transition, so it seems to be executing the post-function at the right time, but not when I use something other than a constant value.

I previously did not have the ^$, but it didn’t pass the syntax checker

When I did the Calculated text custom field, the value was set as expected. For example, creating a new sub-task, the field value changed properly – to reflect the number of sub-tasks.

But I think I was hoping to see if I could get it based off a status transition changing mechanism.

thank you, David

From: Support for JIRA Workflow Toolbox [mailto:support@workflowarts.com] Sent: Thursday, May 11, 2017 4:11 PM To: Kaplan, David David.Kaplan@netapp.com Subject: Re: Question about JIRA Workflow Toolbox

Hi David, ^$ is the regular expression for empty string, since ^ is beginning of input, and $ is end of input. That rule will be triggered only when the field to be checked is not initialized. Which type are the field to be checked and the target field? Thanks, Fidel Castro Armario El 11/5/17 a las 22:04, Kaplan, David escribió: Hi,

During the process of building up functionality in a Post-function for a transition in JIRA, I wanted to set a custom filed to the value of the number of subtasks for the current issue.

I had seen an online posting about setting a field based on other fields I was trying to use something like (^$)count(subtasks())

what is that (^$) notation?

but after transitioning and expecting the post-function to set the field to the number of sub-tasks, the field isn’t being updated. I also tried using %{00027} which equates to Number of Subtasks but that still didn’t work.

I also tried creating a calculated field and that did work, but I was hoping to see if I could populate it as a test after a certain transition and running in the post-function area.

I appreciate any kind of direction on this,

thank you, David

Comments (5)

  1. David Kaplan reporter

    Also, for the times the field does have a value, do I just take the (^$) off of the front? so it would become atoString(count(subtasks())) But first I have to get it to populate

  2. Fidel Castro Armario repo owner

    To execute the setting rule unconditionally, i.e., always, you should use:

    a(.*)toString(count(subtasks()))
    

    Regular expression .* matches any string, even empty string.

  3. David Kaplan reporter

    Thanks Fidel, Your previous recommendation worked. So, one has to add a rule all the time, not just defaulting to - execute all the time?

  4. Fidel Castro Armario repo owner

    For setting a field unconditionally it's simpler to use use "Copy a parsed text to a field" post-function. For example, in your case you should use the following configuration:

    • Target field: Select the field to be set
    • Parsing mode: advanced
    • Text to be parsed: toString(count(subtasks()))
  5. Log in to comment