Scripted field for multi user picker field

Ambica Seshasayee June 6, 2019

Hi,

I have a Scripted field whose template is "User Picker (multiple users".

I have the following script written, but the script is still not loading the field. Can you help?

----

import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import com.atlassian.jira.user.ApplicationUser

import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue;
import java.util.*

import com.atlassian.jira.user.util.UserUtil;
import com.atlassian.jira.user.util.UserManager;

import java.sql.Connection

def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default");

log.error "Good so far 0";

def sqlStmt = """
SELECT bizuser
FROM <myschema>.jbizusers
where <myschema>.jbizusers.jissue=\'""" + issue.getKey() + "\'";

log.error "Good so far 1"
Connection conn = ConnectionFactory.getConnection(helperName);
Sql sql = new Sql(conn);
String user = null;

log.error "Good so far 2";

UserUtil userUtil = ComponentAccessor.getUserUtil();
UserManager userManager = ComponentAccessor.getUserManager();
ApplicationUser jiraUser = null;
List<ApplicationUser> jiraUsers = [];

try {

StringBuffer sb = new StringBuffer();
log.error "Good so far 3";
sql.eachRow(sqlStmt) { row ->
user = "$row.bizuser";
log.error "USER: " + user;
jiraUser = userManager.getUserByName(user);
jiraUsers.add(jiraUser);
//users.add(jiraUser)
}
}
finally {
sql.close()
}

log.error "Good so far 4"
log.error "JiraUsers size: " + jiraUsers.size()
return jiraUsers

 

The Preview for any issue shows the output correctly, with the Application Users identified.

However, the corresponding scripted field is not getting loaded for the same issue.

Any inputs, thanks!

1 answer

0 votes
Josh_Kochelek__Modus_Create
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 Leaders.
August 27, 2019

@Ambica Seshasayee - Did you happen to find a solution for this? I am having the same issue. The preview works fine, but nothing is visible on the issue screen.

Suggest an answer

Log in or Sign up to answer