Hi there!
Originally my goal is to filter available options in select list to depend on selected option in another column.
Lets say I select Option1 in ColumnA and in ColumnB I get available OptionSet1.
If I select Option2 in ColumnA, in ColumnB I get OptionSet2, etc.
Yes, it is like Select List (Cascading), but in Table Grid Editor.
So I tried to create a Behaviour on Groovy, but can't make it work for me. I have this script:
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.plugin.PluginAccessor
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Level
import org.apache.log4j.Logger
log.setLevel Level.DEBUG
String logPref = "Test1234 "
if (log.isDebugEnabled()) log.debug logPref + "START"
// get an issue
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class);
Issue issue = issueManager.getIssueObject("BOM-1");
// find TGE custom fields
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class tgeConfigManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.jira.plugins.igrid.api.config.grid.TGEGridConfigManager");
def tgeConfigManager = ComponentAccessor.getOSGiComponentInstanceOfType(tgeConfigManagerClass);
List<Long> tgeCustomFieldIds = tgeConfigManager.getGridCustomFieldIds();
// get current user
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getOSGiComponentInstanceOfType(JiraAuthenticationContext.class);
Object userObject = jiraAuthenticationContext.getLoggedInUser();
User user = userObject instanceof ApplicationUser ? ((ApplicationUser) userObject).getDirectoryUser() : (User) userObject
// read the grid data
Class dataManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager");
def tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
if (log.isDebugEnabled()) log.debug logPref + "Processing..."
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class)
CustomField tgeCustomField = customFieldManager.getCustomFieldObject(17508)
def callResult1 = tgeGridDataManager.readGridData(issue.getId(), tgeCustomField.id, null, null, 0, 10, user);
if (log.isDebugEnabled()) log.debug logPref + "Result " + callResult1.getValues()
StringBuilder result = new StringBuilder();
for (Long tgeCustomFieldId : tgeCustomFieldIds) {
if (log.isDebugEnabled()) log.debug logPref + "tgeCustomFieldId " + tgeCustomFieldId
try {
def callResult = tgeGridDataManager.readGridData(issue.getId(), tgeCustomFieldId, null, null, 0, 10, user);
result.append("Grid ID=" + tgeCustomFieldId + " content: " + callResult.getValues() + "\n");
if (log.isDebugEnabled()) log.debug logPref + "Result " + callResult.getValues()
} catch (Exception e) {
result.append("Grid ID=" + tgeCustomFieldId + " data cannot be retrieved: " + e.getMessage() + "\n");
}
}
println(result.toString());
return result.toString();
if (log.isDebugEnabled()) log.debug logPref + "END"
It is the only script I could find for table grid editor, there are different versions of it, but in general all they are modified versions of this one. So I tried to use it in behaviour and in post function. In both cases I get following error:
groovy.lang.MissingMethodException: No signature of method: com.idalko.jira.plugins.igrid.impl.data.TGEGridTableDataManagerImpl.readGridData() is applicable for argument types: (java.lang.Long, java.lang.String, null, null, java.lang.Integer, java.lang.Integer, com.atlassian.jira.user.BridgedDirectoryUser) values: [312055, customfield_17508, null, null, 0, 10, x208214:10001]
Possible solutions: readGridData(java.lang.Long, java.lang.Long, java.lang.Long, java.util.Set, java.lang.Integer, java.lang.Integer, com.atlassian.crowd.embedded.api.User)
at BOM_test.run(BOM_test.groovy:39)
As far as I know com.atlassian.crowd.embedded.api.User is deprecated from JIRA and I can't even test properly.
Any ideas why It doesn't work?
If you have an example of how to filter values in columns, I will appreciate it as well.
Thank you in advance.
Hi Viktor,
Maybe I'm misunderstanding your requirement - but cascading from one column to another column can be done without scripting.
Check the example
https://wiki.idalko.com/display/TGPD/How+to+cascade+to+2+%28or+more%29+columns
Is this what you're looking for?
Francis
Hi Francis,
It does seem like what I was looking for. I'm trying to check it,
Thank you for quick turnaround!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it isn't, please send a mail to support.tge@idalko.com which will create an issue on our service desk.
I bumped by accident on this question, and further replies might get unnoticed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.