Forums

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

Custon JQL Function, User in Group from custom field

David Harkins
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 Champions.
May 4, 2023

Trying to get the following custom JQL Function working in data center.

To compare a custom field and check if its group value is in the list of groups that the current user is a member of.

 

package com.onresolve.jira.groovy.jql

import com.atlassian.jira.JiraDataType

import com.atlassian.jira.JiraDataTypes

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.jql.operand.QueryLiteral

import com.atlassian.jira.jql.query.QueryCreationContext

import com.atlassian.jira.permission.ProjectPermissions

import com.atlassian.jira.project.version.VersionManager

import com.atlassian.query.clause.TerminalClause

import com.atlassian.query.operand.FunctionOperand

class AssignedToMyGroups extends AbstractScriptedJqlFunction implements JqlFunction {

    def versionManager = ComponentAccessor.getComponent(VersionManager)

    def permissionManager = ComponentAccessor.getPermissionManager()

 

    @Override

    String getDescription() {

        "Issues where Group field is one of My Groups"

    }

 

    @Override

    List<Map> getArguments() {

        Collections.EMPTY_LIST // <1>

    }

 

    @Override

    String getFunctionName() {

        "AssignedToMyGroups"

    }

 

    @Override

    JiraDataType getDataType() {

        JiraDataTypes.VERSION // <2>

    }

 

    def groupManager = ComponentAccessor.groupManager

    def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

    final username = loggedInUser.username

    @Override

    List<QueryLiteral> getValues(

        groupManager.getGroupNamesForUser(username)

    )

         

}

1 answer

1 accepted

2 votes
Answer accepted
sudhakar
Contributor
June 20, 2018

Hi

We can  get issues work-log/time spent by user using   JQL Search Extensions plugin 

JQL : issue in loggedTimeByUser("daniel") which gives you list of issues that are logged by the user

https://jqlsearchextensions.atlassian.net/wiki/spaces/SEARCH/pages/30497099/JQL+Reference+Server#JQLReference(Server)-LoggedTimeByUser

 

Regards,

Sudhakar

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events