Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I remove spaces when parsing a ticket description to create labels?

Chad Cox October 12, 2021 edited

This is in reference to the JSON below. I am using automation to parse the description to automagically create labels. I need to replace any spaces and swap them with underscores during the label creation, as spaces obviously are not allowed in labels.

Some of the labels I want to create that come right after the ":: " in the description contain spaces, and I need to replace them with underscores in the add label portion in order for this automation to work.

Does anybody know how I should write the JSON for this to work for me?

Any help would be greatly appreciated.

Thanks!

 

 

{
"update": {
"labels": [{
"add": "{{issue.description.subStringBetween("AssetCare Application :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("AssetCare Solution :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Portfolio : ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Host :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Asset Identifier :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Asset Type :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Alert Condition :: ",";")}}"
},
{
"add": "{{issue.description.subStringBetween("Alert State :: ",";")}}"
}
]
}
}

1 answer

1 accepted

2 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 12, 2021

Hi @Chad Cox 

Use the following on every add you've got:

{{issue.description.subStringBetween("AssetCare Application :: ",";").replace(" ", "_")}}

This will replace every space with an underscore.

Let me know if that helps :)

Chad Cox October 12, 2021 edited

Hi Alex,

I appreciated the swift reply. I tried that and it didn't like it, unfortunately... not sure why. I moved on to doing some more detailed if/else combos using variable creation to work out some other tweaks as well, and this appears to be working.

Thanks, and take care :)

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 12, 2021

But what are you exactly trying to accomplish? If e.g. you have the text 

AssetCare Application :: Frodo Gandalf Sam; Another Word

 You want the words Frodo, Gandalf and Sam all in one connected with an underscore, or to be different labels?

Chad Cox October 12, 2021

An example would be:

AssetCare Application :: Connected Buildings ;

I want the label to be Connected_buildings. I tried what you recommended as one of my initial tests this morning, but it didn't seem to like it.

Suggest an answer

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

Atlassian Community Events