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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 -
Please advise, so we can assist you further.
Best, Joseph Chung Yin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.