Create a list which is the difference of two People lists
Asked by Paul Benati:

Community,

**System** : Jira Software for Cloud  
**Project type**: Team-managed

I'm attempting to create a list representing the difference between two lists containing multiple People fields. I have two Jira Software multi-user custom People fields: PeopleList1 and PeopleList 2. PeopleList1 contains three users: User1, User2, and User3. PeopleList2 contains two users: User1 and User3. I want to create a variable that contains the difference between these two lists (i.e., User2). Is this possible? And if so, then how? Thanks.

I've attempted to create a variable via the following smart-value logic, but clearly this isn't going to work.

{{#PeopleList1}}{{#if({{#PeopleList2}}{{accountId.match(accountId)}}){{accountId}}{{\^last}},{{/}}{{/}}{{/}}


Answers:
author: Bill Sheboy
body: Hi [@Paul Benati](/t5/user/viewprofilepage/user-id/5175552) -- Welcome to the Atlassian Community!

*Before proceeding...Please note that team-managed project's People fields have limitations in automation rules. I believe there are several open defects on them not being usable in emails, notifications, etc. from rules. If you need to do any of those things please check if what you want to do with the results is possible before proceeding.*

Back to your question...

Short answer: I do not believe finding the list differences is *easily* possible with an automation rule's features.

Longer explanations:

* Once inside of a list iterator (e.g., PeopleList1), other scopes are apparently not visible (e.g., PeopleList2). And so I do not believe other fields in issues or variables are accessible. It can only see the attributes of the iterator, and lower.
* There are no Boolean operators AND, OR, NOT for list contents, or your scenario would be easy

One possible work-arounds would be: write an external service which can do this, pass in the lists with a web request, and use your results.

Kind regards,  
Bill

comments: author: Paul Benati
body: Bill,

Thanks for the feedback.

FWIW, in my actual case, PeopleList1 and PeopleList2 are changelog.from and changelog.to, respectively. This missing capability seems like a natural fit for many changelog examples.

Paul


author: Bill Sheboy
body: Thanks for clarifying.

In your case you only want the differences and are using the change log for a single People field change. I do not know if [{{fieldChange}}](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--fieldChange--) works with people fields, but there are a couple of options there you may want to try:

{{addedFieldChange.valueIds}}  
{{deletedFieldChange.valueIds}}

Those may provide just the added and deleted values, which you could combine for the differences only. Try writing those to the audit log to see what happens...the documentation has some typos on the case of the smart values, so you may need to experiment.


author: Paul Benati
body: Bill,

Many thanks.

Paul


author: Sanjivani Wayal
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) how to use {{deletedFieldChange.valueIds}} in automation i need to get list of people who were deleted from approvers field , but how can i assign this to the custom field


author: Bill Sheboy
body: Hi [@Sanjivani Wayal](/t5/user/viewprofilepage/user-id/5142575)

What type of field is it?

If it is a text field, when you edit the field, you may type / paste in that smart value, it will appear below the field, and then you can select it.

If it is a multiselect user field, you instead could convert that value to a JSON expression, and set the field with an advanced edit: <https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-user-picker-custom-field>

Kind regards,  
Bill


author: Sanjivani Wayal
body: Hi,

I dont think {{deletedFieldChange.valueIds}} is useful for me as it is removing all the values from other field where as i want to add the last removed value from this field to another field


author: Bill Sheboy
body: This is different from what you originally asked:

*...get list of people who were deleted from approvers field...*

Regardless, I believe you are correct: unless the changes are done one value at a time, there is no way to determine the "last" one removed.