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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Delete whitespaces from a String using Smart Value

Edited
Parvaneh Zand
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.
Oct 13, 2020

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.

5 answers

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 (ñ, ç).

ok, the correct syntax is reiterate the function for each case:

{{Name.replace(" ", "").replace("á", "a").replace("é", "e")}}

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.

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.

 

screenshot_1035.png

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 "".

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(" ", "-")}}

 

Like David Vermeir likes this

Awesome, that works! Thx!

you are welcome

This can solve your problem:

 

{{yourfield.replace(" ", "")}}

I've not tested this but I am pretty sure all you need to do is

 

{{issue.myField.trim()}}

Hi @Parvaneh Zand 

 

Have you fixed this issue? Please share possible solution.

 

Thanks 

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)

Screenshot 2021-05-11 at 13.12.48.png

 

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.

Suggest an answer

Log in or Sign up to answer