Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How Get customfield value without selecting any issue (also which a date field has been overwritten) Edited

Hi all, I want to get custom field value with script runner, but without mentioning any information about issue key. I am only want to mention project name. It is possible to find exactly which mentioned field are changed and have counter for it? For example I have date custom fields(D1 and D2) and I glad to know which custom field are modified and which kind of new value that receive. I write simplified script that is not cover for my project. Please help :)  Thanks in advance.

 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.IssueManager

IssueManager issueManager = ComponentAccessor.getIssueManager();

def issue = issueManager.getIssueObject("TEST-3");

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

def changeItems = changeHistoryManager.getAllChangeItems(issue)

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10500");// here replace the ID with ID of your custom field.

def value = (String)issue.getCustomFieldValue(customField);

if(customField != null) {

        issue.getCustomFieldValue(customField);

    def userUtil = ComponentAccessor.getUserUtil()

    def last_change = changeItems.sort(false).last()

    def text1 = "LAST MODIFIED FIELD:"+ last_change["field"]+ "; FROM VALUE:"+ last_change["fromValue"] + "; TO VALUE:"+ last_change["toValue"]

    return text1;

} else {

     return "NO CHANGES"customfield.jpg

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Feb 04, 2020

Hi @Alik ,

You can display the history of updates on an issue using this script : 

import com.atlassian.jira.issue.history.ChangeItemBean
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager

IssueManager issueManager = ComponentAccessor.getIssueManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

def issue = issueManager.getIssueObject("TST-2");

def ch = changeHistoryManager.getChangeHistories(issue)

for(int i=ch.size() - 1; i >= 0; i--){
for (ChangeItemBean bean:ch.get(i).getChangeItemBeans()){
log.error("field : " + bean.getField() + " From : " + bean.getFromString() + " To : " + bean.getToString() + " by : " + ch.get(i).getAuthorKey() + " On date : " + bean.getCreated() )
}
}

Hope that helps.

Antoine

HI @Antoine Berry 

Thanks a lot, I will try today.

Regards

Alik

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - Spring 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

209 views 3 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you