Forums

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

How do I retrieve the updated customfield id when Jira updated IssueEvent is triggered

Fadli Abdul Rahman November 4, 2019

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_FIELDgetNameKey(), nullnull, 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_FIELDgetId(), nullnullissueType.getId(), issueType.getName());

which the second parameter of the new `ChangeItemBean` is the id of the system field.

2 answers

1 vote
Neil
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2019

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.

Piotr Chabelski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 12, 2019

Thanks for the suggestion, I already commented under the ticket. Hopefully the team will reconsider.

0 votes
Maciej Kwidziński
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 18, 2019

I always see the name, not the id, even for system fields.

Tested with description, priority and labels on Jira 8.5.0.

Screenshot 2019-11-18 at 11.53.06.png

Fadli Abdul Rahman November 22, 2019

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.

Piotr Chabelski
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 22, 2019

@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.

Maciej Kwidziński
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2019

 

Here's an IssueEvent, where I changed a system field and two identically named custom fields.field-ids.png

Can you use the `id` to identify the custom field?

William Tan -ServiceRocket- November 24, 2019

@Maciej Kwidziński 

 

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`.

 

Screenshot 2019-11-25 at 10.46.53 AM.pngScreenshot 2019-11-25 at 10.49.09 AM.png

Like # people like this

Suggest an answer

Log in or Sign up to answer