Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Apache Velocity not able to fetch the values from data map sent using Jira Template Renderer

I have developed a Jira Plugin for Server in which I am sending the required data to the velocity template files from the Get Servlet using render method of Template Renderer (

The code for that is given below:

private final TemplateRenderer templateRenderer;

Map<String, Object> data = service.populateDataForPlugin(pkey, pid, token,
manageFieldsRule, hideFieldService, mandateFieldService, configuration);

// To render the velocity template UI with required data
templateRenderer.render("templates/init.vm", data, res.getWriter());

Adding populateDataForPlugin code below:

import com.aidt.managefields.entity.ManageFieldRules;

// Populate data map with required values to fetch it in doGet servlet
    public Map<String, Object> populateDataForPlugin(String pkey, String pid, String token,
            ManageFieldsRule manageFieldsRule, HideFieldService hideFieldService,
            MandateFieldService mandateFieldService, List<AmfConfigurations> configuration) {

        Map<String, Object> data = Maps.newHashMap();
        data.put("pkey", pkey);
        data.put("pid", pid);

        // Fetch existing Manage field rules from database
        List<ManageFieldRules> exisitingRules = manageFieldsRule.getRules();

        List<ManageFieldRules> projectSpecificHidingRules = new ArrayList<>();
        List<ManageFieldRules> projectSpecificMandateRules = new ArrayList<>();

        // Fetch Manage field rules present in current project
        if (exisitingRules != null && !exisitingRules.isEmpty()) {
            for (ManageFieldRules rule : exisitingRules) {
                if (rule.getPid().equals(pid) && rule.getPkey().equals(pkey) && rule.getOperation().equals("Hide")) {
                    String hideIssueTypeIds = rule.getIssueType().replaceAll("\\[", "").replaceAll("\\]", "");
                if (rule.getPid().equals(pid) && rule.getPkey().equals(pkey) && rule.getOperation().equals("Mandate")) {
                    String mandateIssueTypeIds = rule.getIssueType().replaceAll("\\[", "").replaceAll("\\]", "");
        data.put("hideRuleList", projectSpecificHidingRules);
        data.put("mandateRuleList", projectSpecificMandateRules);

        final Project project = projectManager.getProjectByCurrentKey(pkey);

        // Fetch all issue types mapped to current project
        Collection<IssueType> projectSpecificIssueTypes = ComponentAccessor.getIssueTypeSchemeManager()

        // Convert collection of issue type to list of maps with issue type id and issue type name
        List<Map<String, Object>> allIssueTypesInProject = ManageFieldsUtility
        data.put("allIssueTypesInProject", allIssueTypesInProject);

        // Fetch all system fields in jira instance except fields which are already mandated
        List<Field> allSystemFields = mandateFieldService.findSystemFields();

        // Fetch all custom fields if current project is present in it's context
        List<CustomField> projectSpecificCustomFields = hideFieldService
                .projectSpecificCustomFields(Long.parseLong(pid), issueTypes);

        // Fetch list of all custom fields excluding locked and message custom fields
        List<CustomField> customFieldsExLockedMessageCf = hideFieldService
                .fetchCustomFieldsExLockedMessage(projectSpecificCustomFields, managedConfigurationItemService);

        // Concat System fields and Custom fields
        List<Field> allFields = Stream.concat(,

        // Fetch final list of fields which are eligible to hide in current project
        List<Map<String, Object>> eligibleFieldsToHide = ManageFieldsUtility
                .eligibleFieldsToHide(customFieldsExLockedMessageCf, allFields, exisitingRules, configuration);
        data.put("hideIssueFields", eligibleFieldsToHide);

        // Fetch all custom fields in jira instance
        List<CustomField> allCustomFields = cfm.getCustomFieldObjects();

        // Fetch system fields, custom fields excluding locked fields and message custom fields
        List<Map<String, Object>> allFieldsExLockedMessageCf = mandateFieldService
                .findAllFieldsExLockedMessageFields(allCustomFields, managedConfigurationItemService);
        data.put("systemCustomFields", allFieldsExLockedMessageCf);

        // Fetch final list of fields which are eligible to mandate in current project
        List<Map<String, Object>> eligibleFieldsToMandate = ManageFieldsUtility.eligibleFieldsToMandate(allFields,
                exisitingRules, configuration);
        data.put("mandateIssueFields", eligibleFieldsToMandate);

        // Fetch all custom fields excluding locked and message custom fields
        List<Map<String, Object>> allCustomFieldsExLockedMessageCf = hideFieldService
        data.put("allCustomFields", allCustomFieldsExLockedMessageCf);

        // Add generated unique CSRF token
        data.put("csrfToken", token);

        return data;

In my velocity file, I am fetching RuleId from data map which is passed using template renderer using the following code:

#set ($ruleId = $rule.getID())
RuleId is $ruleId

But the value is not getting populated on Jira UI as seen in the attached screenshot:


But when I fetch the same Rule Id value in the backend, the values are present as expected. I am attaching the screenshot: Output_ss

The issue is data is present in the backend but the values are not getting populated on the Jira UI. Can anyone please help me in resolving this issue.

Jira Software version: 9.2.0 and 9.3.0


1 answer

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 01, 2023

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events