Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automation with temporary (trimmed) values not working

bozidar.ercegovac June 24, 2024

Here is my issue. I have set up automation that calls an API. This is how the body looks like

{ "firstName": "{{issue.customfield_10284}}", "lastName": "{{issue.customfield_10285}}", "displayName": "{{issue.customfield_10284}}", "name": "{{issue.customfield_10284}}", "oib": "{{issue.customfield_10265}}", "defaultAccount": { "accountCode": "{{issue.customfield_10247}}" }, "userTid": { "name": "{{issue.customfield_10274}}", "feeFixed": "{{issue.customfield_10278}}", "feePercentage": "{{issue.customfield_10279}}", "buyConfirmation": "{{issue.customfield_10369}}", "multipleScan": "{{issue.customfield_10372}}", "providerId": "{{issue.customfield_10260}}", "isKeksMerchant": true, "eventCategory": { "eventCategoryId": "{{issue.customfield_10280}}" } }, "skipPaymentInfo": true }

The problem lies with providerId. Currently, 10260 is a multi select option, with each option consisting of key-value pairs, like "14 - String".

What I need is just the numeric value. What I've tried to do was setting up a temporary trimmed value 10374, which is a free text format. 


First, I have tried trimming 10260 to 10374 with different functions

{ "fields": { "customfield_10374": "{{issue.customfield_10260.match("^\\d+")}}" } }

{ "fields": { "customfield_10374": "{{issue.customfield_10260.substringBefore(' - ')}}" } }

{ "fields": { "customfield_10374": "{{issue.customfield_10260.split(' - ').first}}" } }


After that I tried replacing the

"providerId": "{{issue.customfield_10260}}

with

"providerId": "{{issue.customfield_10374}}"

in the API. I would just be getting response errors because it turns out that my temporary value was not being saved.

As a control, I have set up comments in Jira issues:

Trimmed value is: {{issue.customfield_10374}}

Full value for (customfield_10260) is: {{issue.customfield_10260}}

The first one returns null, the second one returns "14 - String". In happy path, I would get "14" for the first command.
Not sure why the value is not being saved and even if this approach is doable.


I have also tried to trim the value directly in APi body with different commands, but In this case I am just getting errors

{ "firstName": "{{issue.customfield_10284}}", "lastName": "{{issue.customfield_10285}}", "displayName": "{{issue.customfield_10284}}", "name": "{{issue.customfield_10284}}", "oib": "{{issue.customfield_10265}}", "defaultAccount": { "accountCode": "{{issue.customfield_10247}}" }, "userTid": { "name": "{{issue.customfield_10274}}", "feeFixed": "{{issue.customfield_10278}}", "feePercentage": "{{issue.customfield_10279}}", "buyConfirmation": "{{issue.customfield_10369}}", "multipleScan": "{{issue.customfield_10372}}", "providerId": "{{issue.customfield_10260.match('^\\d+')}}", "isKeksMerchant": true, "eventCategory": { "eventCategoryId": "{{issue.customfield_10280}}" } }, "skipPaymentInfo": false }

Any tips are appreciated.

2 answers

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 24, 2024

Hi @bozidar.ercegovac -- Welcome to the Atlassian Community!

For selection custom fields, the selected value(s) uses the attribute value, like this:

{{issue.customfield_10260.value}}

Once you have that, your other attempts to parse out the number left-of-the-hyphen should work.

However...you also note this is a multiple selection field, and so that expression would produce a result, such as this:

14 - string, 15 - another string, 17 - one more string

But your "providerId" seems to be a single value.  Is that correct?

Kind regards,
Bill

bozidar.ercegovac June 25, 2024

10260 is a multi select, has a drop down, all options are in format "14 - string" etc.

10374 is free text, which is supposed to be used for saving the trimmed value.

So when I test with this mid step:

"Trimmed value is: {{issue.customfield_10374}}

Full value for (customfield_10260) is: {{issue.customfield_10260}}"

I get, as a result

"Trimmed value is:

Full value for (customfield_10260) is: 14 - String"

The selected drop down value is selected OK, but the trimmed is NULL.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2024

What you describe does not match the behavior I see for multiple-select fields in Jira Cloud automation rules.

 

Please post the following to help diagnose this symptom:

  • in which type of project this rule is defined: company-managed or team-managed
  • if team-managed, where the custom field is defined: site admin (global) or only for the project
  • an image of your complete automation rule (in one continuous image)
  • images of the actions / conditions / branches where you are using that smart value expression
  • an image of the audit log details, showing the rule execution

Thanks!

0 votes
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 24, 2024

@bozidar.ercegovac -

I agreed with what @Bill Sheboy suggested.  To help you to debug, I don't know if you are using the automation audit log - where you can write to the log as an action where you can review what is showing in the audit log.  At the same time, you can create a "local variable" to store the value that you are pulling from your custom field, then you should be able to work on the "local variable" to trim your content.

Here is the link on how to use the Audit Log for automation rule troubleshooting in case you don't already know -

https://support.atlassian.com/cloud-automation/docs/debug-an-automation-rule/

Here is the "Local Variable" concept for automation rule setup link - 

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Create-variable-New-component/ba-p/1448118

Please advise, so we can assist you further.

Best, Joseph Chung Yin

bozidar.ercegovac June 25, 2024

The audit log shows no errors, everything works "as intended" according to them. I have pasted this in other reply

10260 is a multi select, has a drop down, all options are in format "14 - string" etc.

10374 is free text, which is supposed to be used for saving the trimmed value.

So when I test with this mid step:

"Trimmed value is: {{issue.customfield_10374}}

Full value for (customfield_10260) is: {{issue.customfield_10260}}"

I get, as a result

"Trimmed value is:

Full value for (customfield_10260) is: 14 - String"

The selected drop down value is selected OK, but the trimmed is NULL.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events