Forums

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

How can i get the actual running event in scriptrunner during automation?

Markus W_ BENES
Contributor
August 2, 2023

How can i get the actual running event ID or NAME in scriptrunner during automation. the following doesnt work; using 

 

EventTypeManager eventTypeManager = ComponentAccessor.getEventTypeManager()
EventType eventType = eventTypeManager.getEventType(event.getEventTypeId())

leads to:

Something went wrong: MissingPropertyException

No such property: event for class: Script756

 

2 answers

1 vote
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
August 3, 2023

Hi @Markus W_ BENES

Firstly, can you please clarify what the Automation is supposed to do? Is it to create a new issue or update an issue?

If Automation is used to create an issue, it would be best to create a separate listener via ScriptRunner's Listener and add an Issue Created event to get the information.

Alternatively, if you want to get the event details when Automation edits an issue, you can use the listener to track the Issue Updated event.

Please clarify so I can provide an example

Thank you and Kind regards,

Ram

Markus W_ BENES
Contributor
August 3, 2023

@Ram Kumar Aravindakshan _Adaptavist_ Thank you for your Answer! trigger of automation is the add, edit oder delete comment; in automation itself i can get the actual event Type due the smartvalue {{eventType}}. In Scriptrunner this value doesnt exist or i dont know whats the name for it; my actual way to get it is to try it trough the eventTypeManager; but it seems i do something wrong or the method doesnt exist at all.

Markus W_ BENES
Contributor
August 3, 2023

@Ram Kumar Aravindakshan _Adaptavist_  the automation itself should add a text to the comment body and write values to different custom fields depending on the event if the comment is added or edited.

0 votes
Markus W_ BENES
Contributor
August 2, 2023

with this code i can see all event types but how i can i get the actual running eventType of these in automation:

import com.atlassian.jira.event.type.EventType
import com.atlassian.jira.event.type.EventTypeManager
import com.atlassian.jira.component.ComponentAccessor

EventTypeManager etm = ComponentAccessor.getEventTypeManager();
Collection<EventType> alleventTypes = etm.getEventTypes()

def result="";
for (EventType ev : alleventTypes) {
result+=ev.toString()+"<br>";
}

return result;

Suggest an answer

Log in or Sign up to answer