Scriptrunner - get all Service Desk fields

I am writing a listener in Scriptrunner to update another app with info when Service Desk issues are created/updated. But these issues have different fields depending on what they were for.

I know I can grab field data by name but is there some way I can grab them dynamically so that this listener could cover any of the issues?

 

 

1 answer

1 accepted

1 vote
Alexey Matveev Community Champion Nov 15, 2017

Hello,

You could get all changes for the issue been updated by the following code

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {do something}

Thanks. Later in the day, when I changed my search params, I had found something similar:

List<HashMap<String, Object>> fieldsModified = event.getChangeLog()?.getRelated('ChildChangeItem') as List<HashMap<String, Object>>;

for (HashMap<String, Object> field : fieldsModified)
{
log.debug("Field: (${field['field']}), old value: (${field['oldstring']}), new value: (${field['newstring']}).");
}

 While this doesn't give any errors in the Custom Listeners script window it doesn't give me anything in the logs like I would have expected.

Anyway, still playing with it but thanks for the answer.

got this outputting finally, changed log.debug to log.warn. 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Mar 09, 2018 in Jira Service Desk

E.L. Fridge's take on education, Jira Service Desk, and creative Jira use cases

...word of mouth, so by 2016, we were working with several other entities on campus to implement Jira Service Desk . The Atlassian motto of “for every team” has really come true for us in this case. We...

1,239 views 2 14
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you