Forums

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

How to know whether the custom field values are modified or not

Mallela Narender Reddy February 5, 2012

i am having a custom field of type TextField . so when ever i modify the custom field i have to know the old values as well as new values of the custom field .

kind Regards

Naren

2 answers

1 vote
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

In the listener, you will get the event and you can get the Changelog from it. From the changelog, you will get the changegroup id and use it to fetch all the relevant changeitems.

GenericValue changelog = event.getChangelog();
Long changeGroupId = changelog.getLong("id")
List<GenericValue> changeItems = delegator.findByAnd("ChangeItem",EasyMap.build("group", changeGroupId));

Now, iterate over the changeItems and get oldvalue, oldstring, newvalue and newstring to find the changes! field will get you the fieldname.

Mallela Narender Reddy February 7, 2012

Hi
Thanks for the code .It works for me in the edit screen when ever i edit my customfield (ex:textcustomfield) first but when i edit my customfield after editing the other custom fields then my change items are different.

Below is my description with an example:


i have 2 custom field userpicker and textfield


case 1: If i edit my text custom field first and userpicker custom field second then i will get changte items for text custom field
case 2: If i edit userpicker custom field first and my text custom field second then i will get change items for userpicker custom field


so can u plzz give me the code where if i edit my text custom field either first or last , i should get change items for my text custom field

thanks & regards
Naren

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2012

It doesn't matter in which order you edit, you will have a changeItem for each change you make. It seems you are only getting the first changeItem in the list. Get all the changeItems using the groupid, iterate through it and find the one for your custom field. As you can see changeItems is a list!

Mallela Narender Reddy February 8, 2012

Hi
thank u very much , i was able to get the list of change items .iterated and got the result.Problem resolved .thanks once again

regards
Naren

ramesh babu March 3, 2015

Hi Jobin, where do I get the "delegator" .. I am runnign script runner --> custom listener I tried : changeLog.internalDelegator.findByAnd ===> no luck this.delegator ==> no luck --Ramesh

ramesh babu March 3, 2015

I got it from OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator() List<GenericValue> changeItems = delegator.findByAnd("ChangeItem",MapBuilder.build("group", changeGroupId)); ==Worked

0 votes
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

Every issue has a history tab which shows all the changes to all fields of that issue. See http://confluence.atlassian.com/display/JIRA044/Viewing+an+Issue%27s+Change+History

Mallela Narender Reddy February 5, 2012

Thanks for the help , But i required as java code like when ever my custom field is updated my boolean value should be equal to true
......plz help me

Regrds

Naren

Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

Java code? How are you accessing Jira? REST or SOAP? And I guess in both the issue history is not available.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2012

If your code is in a listener, then the changes are listed in the event that the listener catches. Similarly for a post-function - they're in the muteableissue object.

Mallela Narender Reddy February 5, 2012

I am using a listener . In the Listener i want a java code where i can know whether the custom field value is changed or not
if changed my boolean variable should be true . If not changed my boolean value should be false .
I am having issue update event listener but it works for all updates in the issue . So i want only for a particular text field ..

Thanks
Naren

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events