Forums

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

Delete a value from one field and add it to another field

Sina Mathieu June 30, 2025

Hello everyone,

I want to create a rule where I have two fields in a review process (Approved and Rejected). The process is meant for voting on tickets. This means for the rule, if someone has previously rejected a ticket, they will be in the Rejected field, and if they agree to a ticket, they will be in the Approved field.

I want to implement the rule that if someone who previously rejected the ticket then approves it, they are removed from the Rejected field and entered into the Approved field.

I have tried to define the following rule for this:

Unbenannt.PNG

In the action "Edit issue fields" for Rejected, the following code is present:

{{issue.Disapproved.remove(issue.Approved)}}

And for "Approved":
{{issue.Approved}},{{issue.Disapproved}}

The rule does something too, but it throws an error:

Unbenannt.PNG

What am I doing wrong, please? Thank you in advance and best regards,

Sina

2 answers

0 votes
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.
July 1, 2025

Hi @Sina Mathieu 

Who is performing the field update: the person who has now Approved it, or anyone?

 

When it is the person who Approved, please use the {{initiator}} to identify them for the logic to check the Rejected field:

https://confluence.atlassian.com/automation/jira-smart-values-users-993924862.html

And then use text functions to remove them from the selections list, and an iterator with a JSON update to set the values:

https://confluence.atlassian.com/automation/advanced-field-editing-using-json-993924663.html

 

When anyone could make the update and you only want to remove the overlapping people from the Rejected field, please see this article for how to do that:

https://community.atlassian.com/forums/Automation-articles/Automation-concepts-Find-Overlaps-Between-Lists/ba-p/3045704

And once identified, use an iterator and a JSON update to set the values in the Rejected field.

 

Kind regards,
Bill

0 votes
Gor Greyan
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.
July 1, 2025

Hi @Sina Mathieu

Thanks for the question.
The issue is coming from the "Advanced" Edit Issue Fields. It expects valid JSON, and you're providing plain text.

Please try the following ones.

For the "Disapproved" field:

{
"fields": {
"Disapproved": [
{{#issue.Disapproved.remove(issue.Approved)}}{"accountId":"{{accountId}}"}{{^last}},{{/}}{{/}}
]
}
}

For "Approved" field:

{
"fields": {
"Approved": [
{{#issue.Approved}}{"accountId":"{{accountId}}"}{{^last}},{{/}}{{/}},
{{#issue.Disapproved}}{"accountId":"{{accountId}}"}{{^last}},{{/}}{{/}}
]
}
}

Let me know if you have any questions.

Sina Mathieu July 1, 2025

@Gor Greyan 

Thanks for your quick reply. 

The error is no longer thrown now. Unfortunately, the rejected field is now completely cleared, as is the approved field. This applies whether I have two rejectors in my rejected field or just one.

It would be great if the rejector is deleted from the 'Rejected' field and instead appears in the 'Approved' field. If there are two or more rejectors in the 'Rejected' field, it would be perfect if only the one who is now approved appears in the 'Approved' field, while the others remain in the 'Rejected' field. Is there a possibility to realize this?

Best regards

Gor Greyan
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.
July 1, 2025

@Sina Mathieu

Thanks for the feedback.

So, to reach to that goal, we can try this one.

Trigger --> Field Value Changed Approved
Condition --> Disapproved is not empty

Action 1 --> Edit issue --> Disapproved

{
"fields": {
"Disapproved": [
{{#issue.Disapproved}}
{{^equals(accountId, user.accountId)}}
{"accountId": "{{accountId}}"}{{^last}},{{/}}
{{/}}
{{/}}
]
}
}



It loops through each user in Disapproved, removes the user who just triggered the rule, and keeps all others.

Action 2 --> Edit issue --> Approved

{
"fields": {
"Approved": [
{{#issue.Approved}}
{"accountId": "{{accountId}}"}{{^last}},{{/}}
{{/}},
{"accountId": "{{user.accountId}}"}
]
}
}


This keeps existing approvers, and adds the current user to the approved field.

Let me know, if it works.

Sina Mathieu July 1, 2025

@Gor Greyan 

Thanks for your quick reply. 

Unfortunately, the previously rejected individual remains in the Rejected field even after they have approved. They then appear in both the Approved and Rejected fields. When I refresh, both fields are no longer displayed. I suspect this is because the values are completely removed.What can be done about this?

Best regards

Gor Greyan
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.
July 1, 2025

@Sina Mathieu

Sorry for the inconvenience.

Please try this one.

For Disapproved.

{
"fields": {
"Disapproved": [
{{#issue.Disapproved}}
{{#if(ne(accountId,user.accountId))}}
{"accountId": "{{accountId}}"}{{^last}},{{/}}
{{/}}
{{/}}
]
}
}

This checks each user in Disapproved, excludes the user who just approved and preserves others.


For Approved.

{
"fields": {
"Approved": [
{{#issue.Approved}}
{"accountId": "{{accountId}}"}{{^last}},{{/}}
{{/}},
{"accountId": "{{user.accountId}}"}
]
}
}

This adds the approving user to the approval list, keeping existing approvers untouched.

Also use Log Action to see what is the issue.

Filtered Disapproved: {{#issue.Disapproved}}{{#if(ne(accountId,user.accountId))}}{{accountId}}, {{/}}{{/}}

Sina Mathieu July 1, 2025

@Gor Greyan 

Thanks for your help :) I am glad about that.

Unfortunately, the behavior remains unchanged. The fields are completely cleared as soon as you refresh the ticket.

Best regards

Gor Greyan
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.
July 1, 2025

Dear @Sina Mathieu

Thanks for your answer.

Can you inform me if those fields are multi-user pickers?

If yes, please try these in the Log Action to see the result.

Remaining disapproved: {{issue.Disapproved.remove(user)}}
Updated approved: {{issue.Approved.concat(user).distinct}}

Will wait for your answer.

Sina Mathieu July 2, 2025

Hello @Gor Greyan ,

this is a multi-user picker field.

Sorry, i'm a complete noob, what do you mean with "Log Action"? Where should i insert this code?

 

Best regards

 

Gor Greyan
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.
July 3, 2025

Hello @Sina Mathieu

In Jira, Log action is a step you can add to your rule that writes information to the rule audit log. It's super helpful for debugging what smart values.
So before the action, put Action Type --> Log Action and put the following into it, after that, run the automation.


Logged-in user: {{user.accountId}}
All Disapproved users: {{issue.Disapproved}}
After removing current user: {{issue.Disapproved.remove(user)}}
Approved list with current user: {{issue.Approved.concat(user).distinct}}

Sina Mathieu July 4, 2025

@Gor Greyan 

thanks for your quick reply.

All points from the Log Action remain empty. The only point that outputs values is "All disapproved users".

Could it be related to the fact that I am using Data Centers?

Best regards

 

Gor Greyan
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.
July 4, 2025

Hi @Sina Mathieu
Thanks for the answer.

Yes, it is from the DataCenter version. In Jira Data Center, it is still used username or display name.

Try the following one.

For Disapproved:
{
"fields": {
"Disapproved": [
{{#issue.Disapproved}}
{{^equals(name, user.name)}}
{"name": "{{name}}"}{{^last}},{{/}}
{{/}}
{{/}}
]
}
}

For Approved.
{
"fields": {
"Approved": [
{{#issue.Approved}}
{"name": "{{name}}"},
{{/}}
{"name": "{{user.name}}"}
]
}
}


And set this into the Audit Log.
Current user: {{user.name}} / {{user.displayName}}
All disapproved: {{#issue.Disapproved}}{{name}}, {{/}}
All approved: {{#issue.Approved}}{{name}}, {{/}}

Will wait for the feedback.

Sina Mathieu July 4, 2025

@Gor Greyan 

Thanks for that. 

The fields are no longer being cleared, however, the values have not changed either; all values remain unchanged in both fields. In the Log Action, only the value 'Current User' is left blank. For the other values, the colleagues I entered for 'Approved' and 'Rejected' are displayed.

Best regards

Gor Greyan
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.
July 5, 2025

Hi @Sina Mathieu

I think it comes from the 'user'  smart value, as it does not always resolve like it does in Jira Cloud. Let's try this one, changing 'user' smart value.

Disapproved.
{
"fields": {
"Disapproved": [
{{#issue.Disapproved}}
{{^equals(name, initiator.name)}}
{"name": "{{name}}"}{{^last}},{{/}}
{{/}}
{{/}}
]
}
}


Approved.
{
"fields": {
"Approved": [
{{#issue.Approved}}
{"name": "{{name}}"},
{{/}}
{"name": "{{initiator.name}}"}
]
}
}

Sina Mathieu July 6, 2025

@Gor Greyan 

thanks for your quick reply.

Unfortunately, the value from "Rejected" is not deleted; two colleagues initially declined and then one of them accepted. The colleague is now listed under "Rejected" and "Approved".

Best regards

Suggest an answer

Log in or Sign up to answer