Hi everyone,
I want to get a String without whitespaces using smart values (in Project Automation), which copies values of a Multi-user picker field into a single-line text field.
By simply using {{issue.myField}}, It puts white spaces between usernames:
usernameA, usernameB, usernameC
I've tried :
{{issue.myField.remove("")}}
and
{{issue.myField.deleteWhitespace()}}
but all characters were deleted!
Do you know how I can remove those spaces?
Thanks.
Hi everybody,
Thanks by this solution, this helped me a lot.
But, I can use it .replace(" ", "")}} more than once?
For example:
{{Name.replace(" ", "") ("á", "a") ("é", "e")}} etc
In my work use the name of employe for create the email and need replace the characters with accents and umlaut or specials (ñ, ç).
Couldn't get it to work. I have a field `issue.Domain` but when I create a variable (Smart Value) called DomainLabel with {{issue.Domain.replace(" ", "")}} it just returns an empty string.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
Is possible that atlassian not recognize the name of your field, trial use with this sintax:
{{issue.customfield_XXX.replace(" ", "")}}
Wherein XXX is the ID of the field. This ID you can see in the URL of setting of the field, in the image is the las number.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aaron,
doesn't work either. For full context, the custom field is a list of which only one option can be selected (only text values). What I'm trying to do is use a web request automation rule that labels a linked Confluence page with the "Domain" value of the issue. Domain values can have spaces however, so I want to replace the spaces with "-" so Confluence doesn't create a label per word in the selected Domain value.
API: https://<tenant>.atlassian.net/wiki/rest/api/content/{{createdPage.id}}/label
Method: POST
Body:
[
{
"prefix": "global",
"name": "project-overview"
},
{
"prefix": "global",
"name": "{{issue.Domain.replace(" ", "-")}}"
}
]
I thought the double quotes inside the replace function are causing issues with escaping, but when I copy the code to a Create Variable automation component the behaviour is the same. It just returns "".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David
If you use a select field, you need add ".value" in the syntax for indicate that use this, in your case:
{{issue.Domain.value.replace(" ", "-")}}
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.
Hello @Aaron P. , we tried the {{issue.customfield_XXX.replace(" ", "-")}} while editing another custom field to replace the spaces in between with a hyphen, however it wouldn't recognize this as a smart value, and it wouldn't add the value. Could you help suggest on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This can solve your problem:
{{yourfield.replace(" ", "")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Renan Gomes , we tried the {{issue.customfield_XXX.replace(" ", "-")}} while editing another custom field to replace the spaces in between with a hyphen, however it wouldn't recognize this as a smart value, and it wouldn't add the value. Could you help suggest on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've not tested this but I am pretty sure all you need to do is
{{issue.myField.trim()}}
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.
I am not sure you still need it but I was facing the same issue and I found a workaround.
Use the Create Variable component to create the smart value without the space (using remove or Replace function)
For some reason, the Edit issue field component did not work for me each time I tried to type the character space. But editing inside the create Variable component worked perfectly.
You can then use those smart variables inside the Edit Issue Field component.
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.