Hi,
I would like to have a custom field that gets its values from the project component.
Is there a way to do so other than creating a multi select field with all the values?
If there isn't one, how can I use smart values in automation to copy the components values to the custom field and vice versa?
Thanks
Dd
Hi @Dd
If your custom field is text field use below smart value:
{
"fields": {
"customfield_XXXXX": [{{#issue.components}}{{#if notLast}}"{{name}}",{{else}}"{{name}}"{{/if}}{{/}}]
}
}
Replace customfield_XXXXX
with your custom field's ID.
I get the following error (I replaced the XXXXX with the field number)
Error while parsing additional fields - Closing tag (if) does not match opening tag (if notLast)
How do I correct that?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Dd,
Try this one :)
{
"fields": {
"your_multi_field": [{{#issue.components}}{"value":"{{name}}"}{{^last}},{{/}}{{/}}]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried the following:
{
"fields": {
"issue.customfield_10272": [{{#issue.components}}{"value":"{{name}}"}{{^last}},{{/}}{{/}}]
}
}
I used the customfield defintion and got the following error in the Audit Log:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dd, hm... Is the custom field ID correct? Try to use the name of the field instead.
Here's my rule as reference:
"Multi" is the name of my test multi-select field. The rule runs successfully.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The automation ran but the field wasn't updated.
{
"fields": {
"Proposed Components": [{{#issue.components}}{"value":"{{name}}"}{{^last}},{{/}}{{/}}]
}
}
Could it be that I miss the "issue" prefix (though in your example it doesn't appear)? that's why I used the custom notation.
If I need to add it, how do u do that with a custom field that is constructed from 2 words?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dd, the rule an without any errors in the log?
Maybe the Components field is simply empty in the ticket you're using for testing? In the rule, you copy all the components from the ticket to the Proposed Components field, so if there are no components in the ticket, your custom field won't be updated.
As for the prefix for "Proposed Components", you don't have to use "issue", but if you want, you can use "issue.Proposed Components". "Proposed Components" and "issue.Proposed Components" mean the same here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I look at a filter that shows both fields, so I know that the Components field does have a value.
The Proposed Components has a value too - I want it to change (I assume that's not the issue).
The audit log just states that no changes were made.
I can add the issue but if you say it's redundant - then I won't.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dd
I saw that you faced an error during the parsing.
Check the following one.
{
"fields": {
"customfield_XXXXX": [
{{#each issue.components}}
"{{name}}"{{#unless @last}},{{/unless}}
{{/each}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dd
Thanks for the answer.
{
"fields": {
"customfield_XXXXX": [
{{#each issue.components}}
"{{name}}"{{#if @last}}{{else}},{{/if}}
{{/each}}
]
}
}
Kindly ask you also try this one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dd
Thanks for the feedback.
Let's also try this one.
{
"fields": {
"customfield_XXXXX": [
{{#each issue.components}}"{{name}}"{{#unless @last}}, {{/unless}}{{/each}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
{
"fields": {
"components": [
{{#each issue.customfield_XXXXX}}"{{.}}"{{#unless @last}},{{/unless}}{{/each}}
]
}
}
Hey @Dd
Thanks for the feedback.
Please try this one, I have added {{.}}, which is used when iterating over a list of strings instead of objects
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
{
"fields": {
"components": [
{{#each issue.customfield_XXXXX}}
"{{this}}"{{#unless @last}},{{/unless}}
{{/each}}
]
}
}
Hi @Dd
Please try this one :(
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.