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

Using conditional logic to remove "_"

Gilad Waldman
Contributor
August 11, 2024

Hello Community,

Fighting this one up to a point i could really wish some help..

I have an automation rule that triggers every time a new customer is added to a list from Salesforce. It is than look for spaces and replaces them with "_" as it will be transform to a label field. 

1.png

At this point i run on each customer, validate it, adding specific comments and update the label field.

My problem is that sometimes i get a space at the beginning of the customer name, causing it to be looking like "_Customer" instead of "Customer"

 

Been trying to use multiple ways (2 examples), but none are working....

 

1. {{#if(({{Custo}}.startsWith("_")),({{Custo}}.substringAfter("_")),{{Custo}})}}{{/}}

 

2. {{#if(issue.customfield_10193.replace(" ","_").startsWith("_")),(issue.customfield_10193.replace(" ","_").substringAfter("_")),(issue.customfield_10193.replace(" ","_"))}}

 

Any idea how can i break the list based on spaces and also validate no space at the beginning? 

 

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
August 11, 2024

Hi @Gilad Waldman 

What are some examples of the contents of your customfield_10193?  That may help to decide when / how to perform the replacement of spacing to underscores.

For example, some possible configurations might be:

  1. Alice (Single value, with no delimiter)
  2. Alice Jones (Single value with first and last name, and no delimiter)
  3. Alice Jones, Bob Smith, Eve (Multiple names with a comma-space delimiter)
  4. Alice Jones,Bob Smith,Eve (Multiple names with a comma delimiter)
  5. etc.

 

From what you describe, I suspect it is a variation of #3, where the delimiter between names is a comma followed by a space.

In that case, you could try:

  • change the source so the delimiter is only a comma
  • replace the delimiter first in the advanced branch source, such as with:
{{issue.customfield_10193.split(", ").join(",").replace(" ","_").split(",")}}

 

Kind regards,
Bill

Gilad Waldman
Contributor
August 11, 2024

Thank you very much @Bill Sheboy

You are correct, my source is similar to #3 and looks like it works with new branch source. 

 

Thanks!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events