I have a custom field that contains alpha, numeric, and special characters.
I need to copy the value to a diff custom field then trim out all values except for the numeric characters.
Right now I have it set to trigger when a value is added to the custom field.
Then edit the issue and copy custom field 1 to custom field 2.
I'm then using "Additional Fields to update the copied text to replace all characters except for the numeric.
The Copy function works but when I get to the step to modify the text I get the following error:
Hi @Chris Case
For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!
Until we see those...
The replace() function only finds / replace text expressions. To use a regular expression please try using the replaceAll() function: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#replaceAll-String-regex--String-replacement-
And please note: it is not documented for automation rules which parts of the Java spec for regular expressions are / are not supported. I recommend trying simpler expressions first, writing the results to the audit log, and confirming they work as you expect before trying to edit the issue fields.
Kind regards,
Bill
Thanks for the rule image, Chris.
I see you are trying to use single-quotes within the replaceAll() function, with that then nested within double-quotes for the JSON expression. That will not work: those all need to be double-quotes within the smart value expression.
One work-around for that is to perform the replacement first, saving the value in a created variable. Then use that created variable in the JSON for the advanced edit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Huzzah! The combo of using the create variable and using double-quotes fixed it and it's now working :)
This is what I ended up with - using the Create variable function and replaceALL smart value (with double-quotes) then using that created variable to add to the other custom field. Thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris:
Try this out in your automation -
Example -
my original string is "Jira Admin IT test 1 please ignore 235"
my smart value used is - "new value - {{issue.summary.replaceAll("[^0-9]","")}}" and I just utilize the "Log action" action to write the output to the audit log. The audit log shows the new value as - "new value - 1235"
Hope this helps. BTW, it is a best practice to get your desired value to output it to audit log for debugging automation rule purpose - https://support.atlassian.com/cloud-automation/docs/debug-an-automation-rule/
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Technology Applications Team
Viasat Inc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you both for your help. First time posting to the community :)
Here are the screenshots of the rule I've been trying to build out (I've removed the extra steps to refresh data.
Note `customfield_10124` is the target where I'm trying to copy the numeric value to and `customfield_10085` is the source where the alphanumeric value is located.
I just tried again by switching to replaceAll but I don't think I'm using it correctly.
Also tried generating a log action and I'm getting the same error (or looks like it's the same).
For additional context the two custom fields are "Label" type fields if that's helpful or if either of you know if those are not supported.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you try to use double quote instead of single quote?
Let me know of your findings.
Best, Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes thank you for your help! The double quotes and using the variable was the key to get it to work. I added the automation I ended up with above for reference.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.