So I think I have done this 1 million times in the past successfully and yet here I am again trying to figure out what is wrong with my JSON. I have to be doing something stupid and I'm just too close to the trees to see it so looking for some fresh eyes.
note: I have spent a lot of time researching existing Community posts and docs but still stuck.
Use case - I am setting up an automation to update the Category field in the children of an epic when that same field is updated in the epic.
Below is a screenshot of the important bit of my rule but below are the variations of the JSON I have attempted.
{
"fields": {
"customfield_43602”: "{{issue.parent.customfield_43602.value}}”
}
}
{
"fields": {
"customfield_43602”: {"{{issue.parent.customfield_43602.value}}” }
}
}
{
"fields": {
"customfield_43602”: {"value": "{{issue.parent.customfield_43602}}” }
}
}
I have verified via log action that {{issue.parent.customfield_43602.value}} yields the desired value.
Update: One thing I noted is that given that this is an Atlassian locked field I checked on the type and it is shown as "Unknown". While it certainly has the behavior of a Single select it may require a different JSON syntax? Will explore...
So I have landed on the solution but have one error to work out but wanted to provide an update here to everyone.
So the clue came when I looked at the field type and being listed as unknown. Ultimately I tried to use "id" instead of name or value based upon this finding. So my current JSON looks like this...
{
"fields": {
"customfield_43602": {
"id": "{{parentCategory}}"
}
}
}
where parentCategory is a variable defined as {{issue.parent.customfield_43602.id}
This WORKED! However, I do get an error that I need to understand...
and I just discovered this old post where the incredible @Mikael Sandberg offers the same solution. Maybe he can offer further context to understand when/why ID is required?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jack Brickey - whenever I have these challenges, I usually get a JSON response of the issue in question via the get issue endpoint, e.g. https://YOURINSTANCE.atlassian.net/rest/api/2/issue/ISSUE-KEY.
This contains for the category field this JSON:
"customfield_10058": {
"self": "https://YOURINSTANCE.atlassian.net/rest/api/2/customFieldOption/10387",
"value": "first",
"id": "10387"
}
Then I use the edit issue endpoint to update that issue and vary the content. For category, it either works with the id or the value with a payload like this:
{
"fields": {
"customfield_10058": {
"value": "first"
}
}
}
Maybe that helps iterating the payload faster to find a solution in the future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jack Brickey If my memory serves me correctly I believe I used this KB as a reference regarding the Category field. I had a similar automation that needed to set the category when a work item was created and at the time you could only use the ID for the value, but it looks like now you can also use the name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jack Brickey I got the same error, when I forgot to remove the field from the Choose fields dropdown
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys!!!
@Mikael Sandberg , the KB is a great resource, however, i could not get value to work which is what was driving me mad. In the KB they use actual text, e.g. "Marketing" where I am actually using smart values but I would certainly expect that smart values would be an option. If you get a chance I would love to know if you are successful using value and if so, where my syntax of using value is in error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is something that works for Single Select
{
"fields": {
"customfield_10044": {
"value" : "{{issue.parent.customfield_10044.value}}"
}
}
}
:)
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks @Maciej Dudziak _Forgappify_ ,
indeed it does but was not for "Category" which is a special (?) JWM field. I found you must (?) use "id" instead of value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Maciej Dudziak _Forgappify_ , actually this does work and fundamentally answers my original question. What I was missing and did not initially see in your answer, due to me being heads down in using ID rather than value, was the ".value" within the smart value.
while i was simply using this...
{
"fields": {
"customfield_43602”: {"value": "{{issue.parent.customfield_43602}}” }
}
}
I should have been using this...
{
"fields": {
"customfield_43602”: {"value": "{{issue.parent.customfield_43602.value}}” }
}
}
that was my stupid mistake!
bravo my friend!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Jack Brickey
You can copy from the parent:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @arielei , thank you for responding. Unfortunately, not all fields are available in the drop-down selection. It can be very frustrating especially when the field is an actual system field like Category in this case. This is why I am using the advanced JSON approach and leveraging the custom field ID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Jack Brickey
Like you stated, this is a very common use case of automation rules.
I usually run the below endpoint to verify the operations available for a given field:
https://sitename.atlassian.net/rest/api/3/issue/%7BissueIdOrKey%7D/editmeta
If its a multi-select field that supports add, set, remove operations, the below format might help:
{
"update": {
"customfield_43602": [{
"add": { "value": "{{issue.parent.customfield_43602}}" }
}]
}
}
In case you have tried this already, I look forward to the suggestions from community experts on this.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
PS. Here's the document I'm referring to: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-select-custom-field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks @Karan Sachdev , it isn't multi-select but rather single-select. Good tip on the API. I will check that out. I am quite puzzled by why my initial attemps have not worked based on my past successes. I'm sure it will be obvious once solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jack Brickey, can you share the type of the category field? You can check this endpoint for the type of all the fields: https://ecosystem.atlassian.net/rest/api/2/field (Of course with your own Jira url). If you then copy/paste that information, we might be better able to help you.
Here's an example for Jira Work Management's category field:
{
"id": "customfield_20126",
"key": "customfield_20126",
"name": "Category",
"untranslatedName": "Category",
"custom": true,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames":
[
"Category[Category]",
"cf[20126]"
],
"schema":
{
"type": "option",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:jwm-category",
"customId": 20126
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks @Matthias Gaiser _K15t_ , indeed this is what i get as well. just a different id number. So is there somewhere that explains that using "id" for "type" = "option" is required or maybe it isn't?
Basically, my question is this, what bit of information dictates the need of using the ID here and how does one know to go down that path?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.