Dear all,
I would like to create my own custom listener for one dedicated project ( I can select this one in the dropdownlist ), by including events ProjectComponentCreatedEvent, ProjectComponentDeletedEvent.
At this time, I don't know how to retrieve the list of dedicated projects which can trigger this event.
I know that I can retrieve event objects ( event instanceof ProjectComponentCreatedEvent )
Second things : If I Create a new component in another project that one's selected in the custom listener, the event will be triggered !!
In fact, i'm doing a synchronization between one parent project and other project from the same 'Project Catégory'.
Can you provide me such informations please?
here some code source:
import com.atlassian.jira.event.bc.project.component.ProjectComponentCreatedEvent
import com.atlassian.jira.event.bc.project.component.ProjectComponentDeletedEvent
import com.atlassian.jira.event.bc.project.component.ProjectComponentUpdatedEvent
import com.atlassian.jira.bc.project.component.ProjectComponentImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectCategory;
import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.bc.project.component.ProjectComponentManager;
//retrieve the id of the parent , in this case it is hardcoded, because I don't know how to retrieve it
Project projectInitiale = ComponentAccessor.getProjectManager().getProjectObjByKey("PARENT");
Set<String> setOfDeliveryProject = ComponentAccessor.getProjectManager().getAllProjectKeys(projectInitiale.id);
//retrieve the category of projectInitiale
ProjectCategory projectCategory = projectInitiale.getProjectCategory();
ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager()
//retrieve the collection of project with the category given as param
Collection<Project> collectionProject = ComponentAccessor.getProjectManager().getProjectsFromProjectCategory( projectCategory)
if(event instanceof ProjectComponentCreatedEvent){
def event = event as ProjectComponentCreatedEvent
ProjectComponent newProjectComponent = event.getProjectComponent() as ProjectComponentImpl
}
if(event instanceof ProjectComponentDeletedEvent){
}
Thanks in advance,
Cédric
Hi Cédric,
Project filtration only applies to certain types of events, primarily issue-related ones. ScriptRunner does not currently extract project information from component-related events for filtration purposes, so the value of the Project(s) field in the listener config will have no effect in this case.
To achieve the project-specific action you want, you will need to filter explicitly in the code by checking event.projectComponent.projectId, which will be the numeric ID of the relevant project. Then you can decide whether to continue with the script or return early.
Yours,
Joanna Choules, Adaptavist Product Support
Hi @PIERSON Cédric and @Joanna Choules
Actually i have 2 script listenner : one for create a componet between project and another for update a component
But actually i'm dont find a function for delete a component , when i delete componet for the project A (with the project key) in the project B he delete him too
You have idea ???
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dear @Salim Hammar , what did you put as Event ?
if you remove the RemoveEvent, nothing will happen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.