Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,464
Community Members
 
Community Events
168
Community Groups

Use JIRA automation to split an existing field value and populate other field values from that

Can we use JIRA automation to run on a schedule time and extract/split 2-3 values from an existing JIRA field value and populate other fields based on that may be using javascript?

2 answers

0 votes
Daniel Ebers Community Leader May 23, 2021

Hi @Amit Gandhi

your requirement should be met by the following rule. Please double check if this is what you were looking for.
In case of questions Community is happy to assist.

From your description I seem to have understood the field (here Business Unit) is structured the following, data should be split into BU1, BU2, BU3:

grafik.png

This is the rule which is doing that:

grafik.png

Please note: The Trigger "Issue commented" is just an example, you can choose the trigger that suits the best.

The "Edit issue fields" actions are as follows:

BU1:

grafik.png

BU2:

grafik.png

BU3:

grafik.png

Regards,
Daniel

Thanks.

 

How can we find the exact field name to be used in the script, like Business Unit in below example?

issue.fields.Business Unit.value

Daniel Ebers Community Leader Jun 07, 2021

In case it is a cascading select field you can just use the name, like in my example.
Otherwise or if you want to understand the whole topic better, here is the corresponding documentation:
https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

Like # people like this

Will this work if BU1, BU2 and BU3 are read-only text fields?

I tried with one automation test rule in which the rule ran successfully showing field edited successfully but the field was not updated as expected.

 

I basically want these fields to be populated/edited through jiira automation ONLY.

Daniel Ebers Community Leader Jun 11, 2021

I cannot imagine it would work when you try to put values into a read-only field.
This would be a bit counter intuitive even from a code's perspective.

While reading your question again I think you might be asking that you want it to have updated/edited by automation but protect it from an user editing it afterwards, manually.

Yes, this should be possible when to take the field away from "edit screen".

@Daniel Ebers I am trying to solve the same issue. 

I have a Single Select field

EMEA - Italy
EMEA - Greece

In your scenario i assume BU1 and BU2 are text fields. 

Want to split and populate the values in two single select fields. Meaning -->

Field 1 (Single select) - EMEA

Field 2 (Single select) - Greece

Do we need to have the same options in the field ? How to approach it ?

This worked {{issue.customfield_XXXX.value.substringBefore(" - ")}} for me, Thanks

0 votes
John Funk Community Leader May 18, 2021

Hi Amit - can you give an exact example? 

Existing field is a two level dropdown list with below values for example:

First dropdown: X

Second dropdown: Y (Z)

That means the field value as a whole is: X - Y (Z)

 

Now, when I run the JIRA automation rule, it should split the above values into X, Y and Z and populate another three jira fields with these values, like, say,

 

Field1 with value X

Field2 with value Y

Field3 with value Z

Thanks for the update. 

Take a look at this previous post for some guidance. That should get you Field1 and Field2 but I am not sure how you will get Field3 since it is included in the second half (child value) of the field. 

https://community.atlassian.com/t5/Jira-Service-Management/smart-value-for-cascading-select-field/qaq-p/1482635

Thanks. However, the requirement is to have Field3 value too as I mentioned.

Is there a way to do that, like, by incorporating a custom javascript code?

 

Also, Field1, Field2 and Field3 are the real fields in JIRA that need to be populated for the JIRA card/ticket which is being processed, which has the value 'X - Y (Z)' for the target field which is to be extracted.

John Funk Community Leader May 19, 2021

Why don't you just ask for values for all three fields up front instead of only one field and trying to split them up? 

We have already started planning for a better way like that, which can best fit to our system in place at present.

But again, JIRA automation, if possible as asked, can help us move the values from old two level dropdown field to those three new fields, for cards already populated in that way and can continue to use the automation in this way until the new system changes are in place in a full fledged manner.

 

Regardless, can you please confirm if that use case is possible or not?

John Funk Community Leader May 19, 2021

I would start with moving the values into the first two custom fields first following the guidance above.

Then we can look at how to parse out the values in the second custom field to the third custom field.

I would appreciate your straightforward response on the original ask if it is possible or not. Rest, we will figure out and let you know if your assistance required.

Thanks.

John Funk Community Leader May 21, 2021

As I mentioned in my original response - I don't see how you could populate field 3. Someone else might have that expertise, but I do not. 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events