Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello Team,
I have a select list(single choice) custom field and once I enter the value in, I need to add the name of the user who updated the field along with the time updated?
I am working on JIRA cloud and wanted know if in any way it is possible or not?
Thanks and regards,
Danish Hussain Sabunwala
You can achieve this using an automation rule. The trigger would be when the field value is changed for your single-select list.
Your action would be the Edit Issues action, where you would select the text field in which you want to add in the details. If you used a smart value of {{initiator.displayName}}, {{now.jqlDateTime}}, then this would fill the field with User's display name, 2021-06-02 15:15.
This will work if the text field is on the view screen but not on the edit screen, so will remain a read-only field
Hello @Callum Carlile _Automation Consultants_ ,
Thanks a lot for the response.
Maybe my question confused you, sorry for that.
I get that the following, if applied, would only update these values one's and if I try to update it a second time, my first values will be lost.
Example: My single-select list contains : A1 and A2 values. If I select A1 the read-only text field should have "User's display name, 2021-06-02 15:15: now If another user comes and selects A2; Then the read-only text field should have
"User's display name, 2021-06-02 15:15:
Another User's display name, 2021-06-02 16:16:.
Is there any workaround for this?
Thanks and regards,
Danish Hussain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Danish Hussain Sabunwala Yeah this is possible :) if you use the smart value of:
{{issue.name_of_text_field}} : {{initiator.displayName}}, {{now.jqlDateTime}}
The first smart value here just uses whatever's currently in the field, then adds the name and date/time of the initiator to it.
So if a user edits the single-select list the first time:
Name1, date1/time1
...then another user changes this field value
Name1, date1/time1 : Name2, date2/time2
And so on...
You can of course edit the smart value to use any sort of commas, colons or whatever you like to separate the values, I have just used these as an example, the important part is the stuff within the curly brackets
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Callum Carlile _Automation Consultants_ , this is exactly what I was looking for.
Thanks and Regards,
Danish Hussain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This information is actually in the issue's history. Anyway, you can achieve this using ScriptRunner's Script Listeners.
To do that:
1. Navigate ScriptRunner > Script Listeners > Add Listener > make appropriate configurations
2. Under "On these events", choose "Issue Updated" or any events suitable for your use case.
3. Under "Code to run", paste in following snippet:
def result = get("/rest/api/2/issue/${issue.key}/changelog")
.header('Content-Type', 'application/json')
.asObject(Map)
def changes = result.body.values.findAll({
it.items.field == ["Change type"] //Replace with your field name
})
if (!changes.isEmpty()) {
def lastUpdatedBy = changes.last().author.displayName as String
def lastUpdatedTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", changes.last().created).format("yy-MM-dd HH:mm", TimeZone.getTimeZone("Asia/Kuala_Lumpur"))
// get custom fields
def lastUpdatedByCf = get("/rest/api/2/field")
.asObject(List)
.body
.find {(it as Map).name == 'Last Updated'} as Map //Replace with your read-only text field name
def resp = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
(lastUpdatedByCf.id): lastUpdatedBy + ", " + lastUpdatedTime,
]
])
.asString()
}
4. You need to manually set the time zone because you are displaying string and Jira will not adjust automatically to the user's time zone and will always display time in UTC. To check all available time zones., you can run following snippet in ScriptRunner > Script Console:
TimeZone.getAvailableIDs()
An alternative would be implement this using Scripted Fields. The script should be similar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An update to the script, which is more efficient:
def hasFieldChanged = changelog.items.any { it.field == "Change type" } //Replace with your monitoring field name
if (hasFieldChanged) {
def fullChangelog = get("/rest/api/2/issue/${issue.key}/changelog")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
.values
.last()
def lastUpdatedBy = fullChangelog.author.displayName as String
def lastUpdatedTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", fullChangelog.created).format("yy-MM-dd HH:mm", TimeZone.getTimeZone("Asia/Kuala_Lumpur"))
def lastUpdatedByCf = get("/rest/api/2/field")
.asObject(List)
.body
.find {(it as Map).name == 'Last Updated'} as Map //Replace with your read-only text field name
def resp = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
(lastUpdatedByCf.id): lastUpdatedBy + ", " + lastUpdatedTime,
]
])
.asString()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.