Inside the method `issueUpdated(IssueEvent issueEvent)#AbstractIssueEventListener`,
when we call
issueEvent.getChangeLog.getRelated("ChildChangeItem")
it will return a `GenericValue` which consists of the updated field.
For the returned `GenericValue` if the `issuetype` = `jira`, the value of `field` is the `id` of the jira field, but for custom field which the `issuetype` = `custom` the value of `field` is the `name` of the custom field instead of the `id` of the custom field.
Is there any way that I can retrieve the updated custom field id from the `changeLog`?
I've done a quick look on method `updateValue()#ImmutableCustomField` which will update the `ChangeItem` with
new ChangeItemBean(ChangeItemBean.CUSTOM_FIELD, getNameKey(), null, null, changelogValue, changelogString);
which the second parameter of the new `ChangeItemBean` is the name of custom field. While in `updateValue()#IssueTypeSystemField`, it will update the `ChangeItem` with
new ChangeItemBean(ChangeItemBean.STATIC_FIELD, getId(), null, null, issueType.getId(), issueType.getName());
which the second parameter of the new `ChangeItemBean` is the id of the system field.
There was a feature request posted a while back about this: https://jira.atlassian.com/browse/JRASERVER-65473
Unfortunately, it wasn't taken up by the team. If you can't implement a feasible workaround (i.e. using unique custom field names), consider commenting on that ticket and appeal reconsideration.
Thanks for the suggestion, I already commented under the ticket. Hopefully the team will reconsider.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I always see the name, not the id, even for system fields.
Tested with description, priority and labels on Jira 8.5.0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Maciej Kwidziński ,
Thanks for the reply.
Sorry, what I meant by {{id}} for the jira system field was referring to that field unique key identifier. Which for the jira field always the field name with all small letters.
But for the custom fields, the only unique key identifier was always the custom field id.
Is there any way that I can retrieve the unique key identifier for the custom field that coming from the changelog?
I really appreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Maciej Kwidziński @Fadli Abdul Rahman
Our goal is to know from the change log which custom field has changed.
Long story short, for system fields what we're getting in the change log is the field key, which may be similar to its label, but is unique and thus is enough to identify with confidence which field has changed.
However, in the case of custom fields, what we're getting is the label. It is very much possible for a user to create multiple fields by the same name, which makes it very difficult to determine which field is it.
Given the circumstances, we have considered to match it by both the label and the value from the change log, but this proves to be very troublesome for object values (as what we have in the change log is a stringified value) and would require us to awkwardly match it for every custom field type. In the end we abandoned this idea.
Instead, we simply assume all the fields with the label from the change log have changed instead. We get all the available custom fields, filter them by label and assume all of the results should trigger our logic. This is naive and may lead to some side effects, but it's the best temporary workaround we could think of.
Would welcome any alternative suggestions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's an IssueEvent, where I changed a system field and two identically named custom fields.
Can you use the `id` to identify the custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply!.
No, we can't use the `id` field as the `id` field isn't the custom field's `id` but the change-item's `id`.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.