Copy comment author into custom userpicker field - Automation for Jira
Asked by Jason Thompson:

Hello,

I am looking for help using Automation for JIRA to copy the author from the last ticket comment into a custom (user Picker) field, when a ticket is commented on.  
As shown below in the screenshot. (In this instance, I manually edited the field)

The reason is, I would like to be able to setup a JQL filter, to filter the last comment author against the tickets assignee.

![overview.png](https://community.atlassian.com/t5/image/serverpage/image-id/127543i6F3956E04A4CF465/image-size/large?v=v2&px=999 "overview.png")

I have setup the custom field 'Last Commented User' customFieldId=10603

and the Automation for JIRA rule looks like this.

![rule.png](https://community.atlassian.com/t5/image/serverpage/image-id/127544iA86B3907949639E4/image-size/large?v=v2&px=999 "rule.png")

The rule failed error messages look like this.

![audit.png](https://community.atlassian.com/t5/image/serverpage/image-id/127545i50734ABC1B03070B/image-size/large?v=v2&px=999 "audit.png")  
Can anyone provide any advice?

Thanks ...

F.Y.I, we are running the below (server) versions ...

JIRA Service Desk 3.16.0  
Jira Software 7.13.0  
Jira Core 7.13.0  
Automation for Jira 7.2.3


Answers:
author: Bill Sheboy
body: Hi [@Jason Thompson](/t5/user/viewprofilepage/user-id/3937643)

Have you already solved this question? If not, I wondered about two things:

* Have you confirmed the custom field ID you are using matches that field name? Your admin can check that, or you can use this how-to when you need the smart value name for a field: <https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/>
* Next, in your JSON to edit the custome field, it appears that you are trying to set a display name to an account ID. That does not appear to be what you described wanting to do: set the custom user field to the last commentor.

<br />

Best regards,

Bill

comments: author: Jason Thompson
body: Hello Bill,

Thank you very much for the reply and advice.  
No I have not managed to get this working yet ...

I am fairly sure I have the correct field ID, see image below.

![2021-03-22 14_33_14-Configure Custom Field_ Last Commented User - Jira.png](https://community.atlassian.com/t5/image/serverpage/image-id/135369i0DBDB733C24C36A3/image-size/large?v=v2&px=999 "2021-03-22 14_33_14-Configure Custom Field_ Last Commented User - Jira.png")  
Regarding editing the JSON, well I guess this is where I really need the help.  
The JSON I was using i cobbled together from various forum posts with the similar problem, as well the Atlassian Smart Value guides like the one you linked.

I have edited the JSON as below...

![2021-03-22 14_33_55-Project automation - Jira.png](https://community.atlassian.com/t5/image/serverpage/image-id/135367i6AC88983250961E2/image-size/large?v=v2&px=999 "2021-03-22 14_33_55-Project automation - Jira.png")

However I still get the same error message ...

![2021-03-22 14_43_20-Project automation - Jira error message.png](https://community.atlassian.com/t5/image/serverpage/image-id/135368i0EFFCC7A8328036B/image-size/large?v=v2&px=999 "2021-03-22 14_43_20-Project automation - Jira error message.png")

You said in your post "set the custom user field to the last commentor".  
I suppose that is where I get stuck. How do I do that?

Thanks in advance.


author: Bill Sheboy
body: Hi Jason,

You appear to be setting a user field with just the display name. Have you tried to set the last commentor's user to the custom field? And, check that **comments** is plural for the smart value.

```
{
    "fields": {
        "customfield_10603": "{{issue.comments.last.author}}"
    }
}
```


author: Jason Thompson
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Thanks for your help with this problem.

Using information from this post and ...

[Is there a way to see on the queue who was last to comment/update the ticket](https://community.atlassian.com/t5/Jira-Service-Management/Is-there-a-way-to-see-on-the-queue-who-was-last-to-comment/qaq-p/1708628#U1770994)

[Automation Condition - compare lastCommentAuthor = Customer (or participants)](https://community.atlassian.com/t5/Jira-questions/Automation-Condition-compare-lastCommentAuthor-Customer-or/qaq-p/1238912)

... I have been able to solve the issue.

Once again, thanks for your help :)


author: Ashraf B
body: Hi [@Jason Thompson](/t5/user/viewprofilepage/user-id/3937643), [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

I have created a CustomField "Latest Comment By" of "User picker (single user)" type and am trying to populate it using an Automation rule at "Issue commented" event

<br />

Can you share the script, if possible...

Additionally, I am also trying to populate Latest Comment Date, but am still working on it (Field type, etc.)...

Thanks and regards,  

Ashraf B  


author: Bill Sheboy
body: Hi [@Ashraf B](/t5/user/viewprofilepage/user-id/4636755)

Please try by accessing the value for your custom field, such as the following (filling in your own custom field name):

```
{{issue.myCustomFieldName.value.displayName}}
```

Smart values for custom fields are not always obvious, so if you cannot get it to work please the information in this how-to article to identify your custom field's smart value:

<https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

For the [last comment added date](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments--), please try this:

```
{{issue.comments.last.created}}
```

Kind regards,  
Bill


author: Ashraf B
body: Sure [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Thanks again,

Best regards,

Ashraf


Tags: jira-service-desk-server

jira-service-management

jira-service-management-server