hello team
I would like to get all category in instance jira and make it in a select list , maybe i need to work with behaviour .
Have some one idea how to do it , how to get category without using project ?
regards
Alexey Matveev i need your help please.
Hi @[deleted],
Maybe direct from DB?
SELECT * FROM projectcategory;
B.R.
how can i use it in script runner ?
In scriptConsole:
import com.atlassian.jira.component.ComponentAccessorimport groovy.sql.Sqlimport org.ofbiz.core.entity.ConnectionFactoryimport org.ofbiz.core.entity.DelegatorInterfaceimport java.sql.Connectiondef delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)String helperName = delegator.getGroupHelperName("default");def sqlStmt = """SELECT cname FROM projectcategory;"""def resultConnection conn = ConnectionFactory.getConnection(helperName);Sql sql = new Sql(conn)try {StringBuffer sb = new StringBuffer()sql.eachRow(sqlStmt) {sb << "${it.cname}; \n"}result = sb.toString()//log.error sb.toString()}finally {sql.close()}return result
@Andrew thank you but : it works and i get the categorie of jira instance , but now i would like to make theese categorie in a select list custom field : i write this code but the problem is how i will call result to be option in the select list .
Please find below my code.
import com.atlassian.jira.component.ComponentAccessorimport groovy.sql.Sqlimport org.ofbiz.core.entity.ConnectionFactoryimport org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)String helperName = delegator.getGroupHelperName("default");
def sqlStmt = """SELECT cname FROM projectcategory;"""def resultConnection conn = ConnectionFactory.getConnection(helperName);Sql sql = new Sql(conn)
try {StringBuffer sb = new StringBuffer()sql.eachRow(sqlStmt) {sb << "${it.cname}; \n"}result = sb.toString()
//log.error sb.toString()}
finally {sql.close()}
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.component.ComponentAccessordef optionsManager = ComponentAccessor.getOptionsManager()def ParticipationTypeField = getFieldByName("Categorie") // your field name here
//Participation Type Field Optionsdef ParticipationTypeCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10201"); // your field ID heredef ParticipationTypeConfig = ParticipationTypeCF.getRelevantConfig(getIssueContext());def ParticipationTypeOptions = optionsManager.getOptions(ParticipationTypeConfig);
// Set the values inside the select list fielddef ParticipationTypeMap = [null: "Noneeeeeee"]
ParticipationTypeMap += ParticipationTypeOptions.findAll {
it.value in [result, "c"] ////////////////////// how can i make the value of the result in the option////////////////////////////////////
}.collectEntries {[(it.optionId): it.value]}
ParticipationTypeField.setFieldOptions(ParticipationTypeMap);
log.warn("***** ParticipationTypeOptions **** " + ParticipationTypeOptions);
It looks like you're new here. Sign in or register to get started.