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

Listener not working if project name is not specified

Hi 
I have written a listener to change the Assignee to component lead when ever component is being changed. I can see in the log and backend script is executing and component owner/assignee is being changed. But on UI unless the project name is mentioned , assignee field value is not being changed. 

Is it mandatory to mention the project name for listeners

2 answers

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Nov 29, 2019

Hi @Vineela Durbha ,

You should set the project in the listener configuration. Do you mean you needed to mention the project name in the script ?

Hi @Antoine Berry 

I am talking about mentioning the project in listener configuration. Actually I have the script which should work for the entire project category.So I am looking for what happens if project name is not added under the listener configuration, as my script should work for the entire project category.

Antoine Berry Community Leader Dec 03, 2019

Sorry I completely missed your answer... As Ilya said you could create a listener for all projects and filter the project category in the script itself.

@Antoine Berry 

I tried the above but it is not working unless and until you provide the project name in script listener UI page

Antoine Berry Community Leader Dec 04, 2019

@Vineela Durbha could you please provide a screenshot of you configuration / script ? It would be easier to debug it.

@Antoine Berry 

Please find the attached screenshot . I have tried not to mention any project under projects and because of this assignee value is not getting changed inspite of mentioning that in the script. My script is as below

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent;
import org.apache.log4j.Level
import org.apache.log4j.Logger

Helper helper = new Helper();

log.setLevel(org.apache.log4j.Level.DEBUG)
def issue = event.issue as Issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager();

def changeHolder = new DefaultIssueChangeHolder();

 

log.debug("project category" +issue.getProjectObject().getProjectCategoryObject().getName())

def components = issue.componentObjects.toList()

if(issue.getProjectObject().getProjectCategoryObject().getName()=="Software - Lightweight"){
if(helper.CheckIfSpecificCustomFieldChangedValue(event,"Component"))
{
log.debug("yes component value is changed")
issue.setAssignee(components?.first()?.componentLead)
log.debug("assignee " +issue.getAssignee().getDisplayName())
}
}

 

This works only if I mention specific project under projects in Listener UI. But when i try to display the assignee value in the script, I can see the new assignee but the value is not being reflected on UI. So I guess value is getting changed but not being reflected in UICapture.PNG

Antoine Berry Community Leader Dec 04, 2019

With that current configuration the listener will indeed not execute, kindly try to map it with all projets : 

image.png

@Antoine Berry 

With All projects it is not working. I can see that script got executed successfully, but on UI assignee value is not changed.Capture.PNG

Antoine Berry Community Leader Dec 04, 2019

If I am not mistaken the script should display the assignee if it is updated ?

Antoine Berry Community Leader Dec 04, 2019

Also you could try to add 

import com.atlassian.jira.issue.index.IssueIndexingService

def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issue.store()
issueIndexingService.reIndex(issue)

after updating the assignee in the script.

Like Vineela Durbha likes this

@Antoine Berry 

By adding above code script is working for "All projects" under Listener. 
Thanks for helping me resolve this issue.

Like Antoine Berry likes this

I guess, since components are bound to a projects, you have to select the context for your listener, "All projects" might work for you (unfortunately, there's no option to select project category).

All projects is not working unless specific projects are mentioned under Listener in UI ,inspite of mentioning the project category under scripts

Suggest an answer

Log in or Sign up to answer
TAGS

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