Forums

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

Jira Automation : Set Custom Field from JSON \ Regex

Evan Nixon
Contributor
November 4, 2021

Hello,

 

I'm currently running the below automation, which outputs the user ID of a user mentioned in a comment like this : 

"accountid:123a456b7891be664"

I'd like to change update a custom user picker field with the account id that has been extracted from this, I can change the JSON to add or remove bits around the string, however I haven't been able to get the custom user picker field to accept anything I've thrown at it so far. 

The regex that finds the accountid is :

\[~accountid:.+\]

 

And the JSON is :

{
"update": {
"customfield_10633": [{
"set": "{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~").remove("]")}}"
}]
}
}

Screenshot 2021-11-04 175122.png

Any ideas on what I'm doing wrong here?

1 answer

0 votes
Sebastian Krzewiński
Community Champion
November 4, 2021

Hi @Evan Nixon 

 

Please try:

{
"update": {
"customfield_10633": [{
"accountid": "{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~").remove("]")}}"
}]
}
}

All needed informations how to set fields via api you can find here: https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/

Evan Nixon
Contributor
November 5, 2021

Hi Sebastian,

Thanks very much for your reply - super appreciated as I'm absolutely banging my head against a wall on this one, unfortunately there's no luck with your suggestion either. Below is your snippet and the error it threw, then my attempt to tweak it with it's failure log as well. Just a heads up that customfield_10632 the correct value for my custom multi-user picker, whereas my original post had 10633 which is a custom rich text field I've been using to test the output. I ran both of the below through both fields and got no results.

{
"update": {
"customfield_10632": [{
"accountid": "{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~").remove("]")}}"
}]
}
}

2.png

 

{
"update": {
"customfield_10632": [{
"set": "{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~").remove("]")}}"
}]
}
}

1.png

I've tested just the below part of the code just to double check

"{{issue.comments.last.body.match("(\[~accountid:.+\])").remove("[~").remove("]")}}"

It's output is :

accountid:[...]

 
I'm still not confident I know if that's the right syntax for the multi-user picker box, if it needs to be wrapped in {{ }}, or even if there's a way to instead use the {{user.key}} instead of the accountid string. Man this stuff can be difficult. 

Sebastian Krzewiński
Community Champion
November 10, 2021

Could you share example input that you have?

Evan Nixon
Contributor
November 10, 2021

@Sebastian Krzewiński I ended up getting past this particular stumbling block, but am now stuck at the very last hurdle. I've given a fair bit more information in this thread regarding the input, output, regex and multi-user picker syntax. Any help you can provide there would be fantastic, cheers!

Like Sebastian Krzewiński likes this

Suggest an answer

Log in or Sign up to answer