Uploaded image for project: 'Automation for Cloud'
  1. Automation for Cloud
  2. AUTO-239

Comparing values in the response of a webhook request against a custom field or smart value using string functions do not work

    • Severity 3 - Minor

      Issue Summary

      Functions, such as if(a), do not use the correct parameter scope when nested more than one level deep.

      {{#lookupIssues}} {{string(summary)}} {{/}}

      works
      but

      {{#lookupIssues.comments}} {{string(body)}} {{/}}

      does not.

      This is also problematic when looping through webhook responses as this is always more than one level deep.

      {{#webhookResponse.body}} {{#if(name.indexOf("Hi!").gt(-1))}}macthed{{/}} {{/}}

      works
      but

      {{#webhookResponse.body}} {{#if(name.indexOf(issue.myField).gt(-1))}}macthed{{/}} {{/}}

      does not

      Steps to Reproduce

      1. Create an empty Software Project -> call it Rugby
      2. Create 2 custom fields
        1. Text Field (single line) -> call it potato
        2. Select List (single choice) -> call it cheese
      3. Add these custom fields to the software project
      4. Create an automation rule in the software project
        1. Create a webhook to retrieve all projects
          1. GET http://<jira base url>/rest/api/2/project
        2. Add the below log actions:
          1. Webhook items: {{#webhookResponse.body}} id {{id}} name {{name}}, {{/}}
            
          1. cheese -> field name dot value: "{{cheese.value}}", issue dot field name dot value: "{{issue.cheese.value}}", issue dot id dot value: "{{issue.customfield_11400.value}}"
            
          • replace customfield_11400 with your own custom field
          • this is just printing the values for the first custom field (cheese) which is of type Select List (single choice)
          • next up are the log actions for this custom field
          1. Webhook contains field name dot value: {{#webhookResponse.body}} {{#if(name.indexOf(cheese.value).gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
          1. Webhook contains issue dot field name dot value: {{#webhookResponse.body}} {{#if(name.indexOf(issue.cheese.value).gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
          1. Webhook contains issue dot field id dot value: {{#webhookResponse.body}} {{#if(name.indexOf(issue.customfield_11400.value).gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
            • replace customfield_11400 with your own custom field
          1. potato -> field name: "{{potato}}", issue dot field name: "{{issue.potato}}", issue dot id: "{{issue.customfield_11100}}"
            
            • replace customfield_11100 with your own custom field
            • this is the second custom field which is of type Text Field (single line)
            • next up are the log actions for this custom field
          1. Webhook contains field name: {{#webhookResponse.body}} {{#if(name.indexOf(potato).gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
          1. Webhook contains issue dot field name: {{#webhookResponse.body}} {{#if(name.indexOf(issue.potato).gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
          1. Webhook contains potato issue dot field id: {{#webhookResponse.body}} {{#if(name.indexOf(issue.customfield_11100).gt(-1))}}  id {{id}} name {{name}} {{/}} {{/}}
            
            • replace customfield_11100 with your own custom field
          1. Webhook contains "rugby": {{#webhookResponse.body}} {{#if(equals(name, "rugby"))}} id {{id}} name {{name}} {{/}} {{/}}
            
          1. Webhook contains "rugby": {{#webhookResponse.body}} {{#if(name.indexOf("rugby").gt(-1))}} id {{id}} name {{name}} {{/}} {{/}}
            
            • And the last 2 log actions that work check the text string rugby directly

      Then create an issue and populate the custom fields with a partial name of the project it should trigger the above automation rule and you should see the problem in the log output as per the screenshot below.

      Expected Results

      We expect to see results for projects that match the values of my custom fields

      Actual Results

      No projects are logs as nothing matches the custom fields, this is not because of the values but because the functions do not work with custom fields:

      The same happens for star values, if you create a smart value in automation you will have the same result as described with custom fields.
       

      Workaround

      Currently, there is no known workaround for this behavior. A workaround will be added here when available

            [AUTO-239] Comparing values in the response of a webhook request against a custom field or smart value using string functions do not work

            This is a Jira bug. The compare function does not work when you are comparing two smart values. I'm using the userInput feature to compare a user selection with a value in an API response, it is not working. The bug was validated by Atlassian support.

            Chris Garstin added a comment - This is a Jira bug. The compare function does not work when you are comparing two smart values. I'm using the userInput feature to compare a user selection with a value in an API response, it is not working. The bug was validated by Atlassian support.

            Hi Team! I would say this isn't Third-party webhooks, but Jira's itself.

            Regards
            Slava

            Slava Gefen added a comment - Hi Team! I would say this isn't Third-party webhooks, but Jira's itself. Regards Slava

              Unassigned Unassigned
              78538e785fe1 Lígia Zanchet
              Affected customers:
              5 This affects my team
              Watchers:
              12 Start watching this issue

                Created:
                Updated: