Hi,
I'm trying to automate some parts of our service desk. One task is automatically adding the project lead as request participant whenever an user requests access to a project as an administrator, and so far, I've got this code snippet (this is the 'search user and add as participant' part):
void addLead() {
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class);
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class);
def query = jqlQueryParser.parseQuery('project="'+(issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("JIRA Project")) as String)+'"');
def results = searchProvider.search(query, issue.assignee, PagerFilter.getUnlimitedFilter());
results.getIssues().each {documentIssue ->
issue.setCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10101"),documentIssue.getProjectObject().getProjectLead() as ArrayList<ApplicationUser>);
return;
}
} While it does not fail in any way, the change is not saved to the issue - script execution is marked as successful but no participant is added. The script is ran as a post-function set before storing&reindexing, so I don't think I need to call updateIssue(), but I'm not certain.
I'm afraid that either the change is not saved or the project is returned, but the query should be working correctly.