Forums

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

Jira Cloud Automation copy to field through Smart Values

Anatoly Ovsyannikov November 17, 2021

Greetings!

To ease statistic collection I've added "Issue Checklist Pro" plug-in and created multi-user picker custom field to collect data from checklist section. And now I'm trying to implement auto-copying of specific information from the field.

Current case:

"Issue Checklist Pro" plug-in allows to tag (mention users) via their names, but transform it to their ID's after changes were applied (at the end it looks like:
"info1 @user1_id
info2 @User2_id" ).
I need these ID's to be copied and paste in multi-user picker custom field (not only one but as many as numbers of ID's mentioned in checklist section)

I'm new to Java Script but trying to use this script with Smart Values for this purpose:

{
          “fields”: {
                  “customfield_10049": [{
                            “id”: “{{issue.customfield_10048.match(“\[a-zA-Z0-9]{24}\“)}}”
                   }]
           }
}

*customfield_10048 - Donor field: "Issue Checklist Pro" plug-in text field
*customfield_10049 - Recipient field: Multi-user picker custom field
*[a-zA-Z0-9]{24} - RegEx for User ID


Tried to correct script many times, but continuing to receive an error: "(data was not an array (customfield_10049))"
(When I use PUT request with specific ID, not RegEx it's working properly)

Could you please help me to retrieve ID's from donor field and put it to Recipient one. 
And somehow make 'issue.field.match' loop though donor field to find all ID's and then insert them into Recipient field.


Thank you in advance!

 

1 answer

2 votes
Jack Hunter [HeroCoders]
Atlassian Partner
November 17, 2021

Hello @Anatoly Ovsyannikov,

 When it comes to the regexp, we use the following in Issue Checklist Pro for user IDs (please note that it supports an older way of mentioning too, so you could probably simplify it):

/(^|\s+)@([a-zA-Z0-9\u0400-\u044f_.+:-]+)/g

 As for the "(data was not an array (customfield_10049))", I think it is due to the smart value / regexp used incorrectly. I hope someone more skilled in Automation can help here. 

Cheers,
Jack

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 17, 2021

Hi @Anatoly Ovsyannikov 

Yes, and...to what @Jack Hunter [HeroCoders]  suggests:

Once you get your id values out of the checklist, you can use text and list functions to get the value into the format shown in this documentation:

https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/#Advancedfieldediting-JSON--Multi-userpickercustomfield

To help build that, I recommend just writing to the audit log initially until it works as expected, and then try the update of the custom field.  Perhaps even put it into a created variable to help prevent parsing errors.

One more thing: if you are using "fields" in the JSON, that takes the place of "update" and "set", so there is no need to use the "put".  Please look here for information on that: https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/#Advancedfieldediting-JSON--What-sthedifferencebetweenupdateandfields

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events