Creating an Issue by copying values from a field

Jamshaid
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.
November 19, 2020

I am having an issue created with Type 1. When a user edits the issue and clicks the update button, it should copy the values from a specific field called Confirmation(which is a customized field and I am able to get values from it).
As the update button is pressed, it should create another issue of Type 2, and copy the values from the confirmation field to a field called Gaps.  Other values should be copied as well from the issue as well(if possible).

It should then take the values from the Gaps field(which I can get from a sample issue created) and create the sub-tasks for the newly created issue.

What Am I able to do?
I am able to run a script when the update button is pressed, copy values from the Gaps field and the confirmation field.


What I am unable to find?

I am unable to find the script/help to write a script which creates an issue. I am able to find a script that creates sub-fields when a new issue is created but it doesn't demonstrate how to create a new issue. Here is the script that creates a sub-task for a newly created issue.

I am new to Jira. Any help would be really appreciated. Thanks a lot

1 answer

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 20, 2020

Hi Jamsahaid,

Why don't you just use Automation For Jira to do all of that? You don't need to write scripts or code and it will do all that you need. 

Here is some more information to get you started:

There are two types of automation:

  • Global: In the Free version, you get 100 executions per product, per month
  • Project: In all versions, you get unlimited executions per month

Automation Basics: https://www.atlassian.com/software/jira/guides/expand-jira/automation

You can do this via global rules to apply to all projects also. You'll need to be a Jira Admin/Site Admin, go to Jira Settings > System > Automation Rules (left-hand menu).

For more on using Automation For Jira see these help pages.

Jamshaid
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.
November 20, 2020

Thanks, John
I will dig into it. I am already an Admin so that won't be an issue to me.

Like John Funk likes this
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.
November 20, 2020

Hi @Jamshaid 

One more automation source for you is the new automation template library, which demonstrates many common use cases:

https://www.atlassian.com/software/jira/automation-template-library#/label/all/1453

Best regards,

Bill

Jamshaid
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.
November 23, 2020

@Bill Sheboy  @John Funk  Could you please guide me about how can I get it working using code? I am not getting the library. Thanks a lot

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 23, 2020

You can’t get to the list of rules?

Jamshaid
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.
November 23, 2020

@Bill Sheboy I have been looking into the library you mentioned, but it seems to contradict my requirements. I have to copy data from a single field which can have several new lines and every new line will create a separate sub-task. The field is named Gaps, which means that it will have multiple gaps and every gap will create a new subtask. Can I achieve them in your suggested library? I don't find a way to do that. thanks a lot  

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.
November 23, 2020

Hi @Jamshaid 

Thank you for clarifying...

Do you know the possible values that could be in the Gaps field (it is a defined list of values), or is it completely dynamic (unknown in advance)?  If it is completely dynamic, I do not know any way to do this with smart values and automation.  There is no generic iterator for looping without the context of an issue list, or list within an issue.

If instead Gaps contains a known list of values...

  1. Let's assume your Gaps field is a string...
  2. Use the If/Else condition and text matching, e.g. indexOf(), to look for a known value
  3. If the value is found, create your sub-task
  4. Else proceed to the next test

Here is the documentation of text and list handling functions to help you:

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/

https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/

 

__Bill

Suggest an answer

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

Atlassian Community Events