I want to retrieve all options of a select custom field. See my code below, I can get the custom field but not able to show its options .. :(
#set ( $c_n = $customFieldManager.getCustomFieldObjectByName("Deptt") ) $c_n.getIdAsLong() #set ( $opts = $c_n.getOptions() ) <ul> #foreach( $opt in $opts ) <li>$opt.getValue()</li> #end </ul>
Community moderators have prevented the ability to post new answers.
hello Muhammed Usman,
you can directly use $configs variable to get the options for that context.
for reference read
and might be #foreach ($option in $configs.options) work to display options.
Hi Bharadwaj,
Thanks for your reply. I cannot make it work.
I am using this code now, what am I missing?
#set ( $c_n = $customFieldManager.getCustomFieldObjectByName("Customer Name") ) <ul> #foreach ($option in $configs.options) <li>$option.value</li> #end </ul>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, but where exactly you want to retrieve the options. I mean in which context the template is used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
which mean you are trying to display the contents of CustomerName as select list in Project Tab Panel?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
not as a select list though. I just want to show these like this:
Department Name:
- Dept 1
- Dept 2
Customer Name:
- Customer Name 1
- Customer Name 2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do you have issue object as a variable in your hand?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No.. I dont have issue object .. I have added new project tab panel named departments .. and on that page I want to show all departments assoicated with the project ( which is available in deptt custom field )...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in that case configs.options will not work.
you create JiraContextTreeManager object in your java class, using that get JiraContextNode object and store in some variable. Pass this variable to your vm file. Now you have JiraContextNode in your hand.
probably you might get options using
$customFieldManager.getCustomFieldObjectByName(
"Deptt"
).getOptions(null,/*variable that stored JiraContextNode object*/)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think no need of creating a new java class, you already might have written class for your Project Tab Panel, in that class itself you try to put the value in the map variable.
I found the following code that pass some values to variables in Version Project Tab Panel
protected Map<String, Object> createVelocityParams(BrowseContext ctx)
{
Project project = ctx.getProject();
List versions = getVersions(project);
Map params = super.createVelocityParams(ctx);
params.put("versionsCount", Integer.valueOf(versions.size()));
Integer subset = getSubset();
Collection versionToDisplay = TabPanelUtil.subSetCollection(versions, subset.intValue());
params.put("versions", versionToDisplay);
params.put("hasAdminPermission", this.permissionHelper.hasProjectAdminPermission(this.authenticationContext.getLoggedInUser(), project));
params.put("showingAll", Boolean.valueOf(versions.size() < 20));
params.put("subset", subset);
params.put("dateFieldFormat", this.dateFieldFormat);
return params;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Line 2 is breaking what you're doing for a start!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Parameters is the issue.
BUT How we can get these parameters in velocity
getOptions(String key, JiraContextNode jiraContextNode)
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.