JIRA Automation: How to use Smart Fields split() function

Iohan Reyes January 8, 2018

I am trying to create a rule that lets me copy an IP address from one field to another, but inserting zeroes in order to make it sortable.

 

i.e.

IP_Field1 == 192.168.0.10

desired outcome:

IP_Field2 == 192.168.000.010

 

My thought was to use a combination of split() and leftpad() to accomplish this.  Please note, I am not a developer and I am attempting to do this just be RTFM-ing the instructions found here: https://codebarrel.atlassian.net/wiki/spaces/AUTO4J/pages/51691794/Working+with+Strings

The instructions show how to access the "first" value in the split, but I am not able to figure how to get the 2nd, 3rd, and 4th octets.

 

Any suggestions?

 

 

 

1 answer

1 vote
Alexey Matveev
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.
January 8, 2018

Hello,

Could you try

{{issue.reporter.IP_Field1.split(" .")[1]}}

for the second octet.

Though I did not check it.

Iohan Reyes January 8, 2018

Hi Alexey, thanks for responding.  Unfortunately that did not work. 

 

This works:

{{issue.reporter.IP_Field1.split(".").first}}

Which is same as example in documentation and produces: 192

 

This also works:

{{issue.reporter.IP_Field1.split(".")}}

and produces: 192, 168, 0, 10

Jens November 15, 2019

Hi Iohan,

I am curious to learn if you found a solution to extract other octets than the first. I have the same problem and I can extract the first octet or get a list of all.

Thanks for your reply

Jens

Like Bill Sheboy likes this
MCrawford June 25, 2020

Has anyone be able to resolve this? I am only able to get the first octet in then split string as well. So for example, I am splitting on "_": 

ACH 1.0_QA_testuat_ex_debit 1.0

and I need to set each as a smart value.

 

issue.summary.split("_")[4]  <-- this did not work

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.
June 25, 2020

Hi @MCrawford -- Welcome to the Atlassian community!

Please try the following:  {{issue.summary.split("_").get(4)}}

The documentation is a bit incomplete; look here for more info: https://community.atlassian.com/t5/Jira-Software-questions/JIRA-automation-and-a-working-example-of-the-Split-function-for/qaq-p/1395718

Best regards,

Bill

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events