Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scriptrunner - get all Service Desk fields

Jon Starbird
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.
November 15, 2017

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

2 votes
Answer accepted
Alexey Matveev
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.
November 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}
Jon Starbird
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.
November 16, 2017

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.

Jon Starbird
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.
November 16, 2017

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events