I am quite new to implement confluence macros.
Requirement is to set dynamic parameter values for the 'enum' field type in the macro browser.
But end up with no success, it was not working for me. Seems some thing I was missing?
Please see my macro definition in atlassian-plugin.xml
<xhtml-macro name="xxxxxx"
title="xxxxxfunctionality"
class="xxxxxx.xxxxxx"
icon="xxxxx/xxxxxxx/${project.groupId}.${project.artifactId}/xxxx/xxxxxxxx.png"
key="xxxxxxxxx-macro">
<description key="xxxxxx.macro.desc"/>
<category name="development"/>
<parameters>
<parameter name="xxxxx" type="enum" required="true" default="None">
</parameter>
</parameters>
</xhtml-macro>
And the JS file here:
(function ($) {
console.log("js file called");
var xxxxxxMacro = function () {};
console.log("js file called 2");
xxxxxxMacro .prototype.fields = {
"enum": {
"xxxxx": function (param, options) {
console.log("js file called 3");
var paramDiv = AJS.$(Confluence.Templates.MacroBrowser.macroParameterSelect());
var xxxxxDropDown = AJS.$("xxxxx", paramDiv);
console.log("inside enum group");
loadXxxxx(xxxxxDropDown);
return new AJS.MacroBrowser.Field(paramDiv, xxxxxDropDown, options);
}
}
};
function loadXxxxx(xxxxxDropDown){
console.log("js file called 4");
xxxxxDropDown.empty();
xxxxxDropDown.append($("<option>color1</option>"));
xxxxxDropDown.append($("<option>color2</option>"));
console.log("call complete");
}
AJS.MacroBrowser.setMacroJsOverride("xxxxxxxxx-macro", new xxxxxxMacro());
})(AJS.$);
Please help me regarding this.
Hi Rambabu
Was the issue resolved? Are you able to populate enum values dynamically?
something like this should work
"xxxxx": function (param, options) {
param.enumValues = ['color1', 'color2'];
//in Confluence 6.6+ you need to specify displayed values, otherwise all dropdown items are displayed as "undefined"
param.enumMapValueName['color1'] = 'color1'
param.enumMapValueName['color2'] = 'color2'
return AJS.MacroBrowser.ParameterFields['enum'](param, options);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also trying to achieve dynamic population of the drop down values. Tried above code which u mentioned. Still I am getting the values as undefined.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems that enumMapValueName is deprecated, use enumToI18nKeyMapping.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.