Is there a to call similar to AJS.MacroBrowser.setMacroJsOverride() that can be made outside a plugin?

I am wondering if there is a way to call AJS.MacroBrowser.setMacroJsOverride() outside of a plugin? For example, calling AJS.MacroBrowser.setMacroJsOverride(“my-macro”, {opener: …}) from the customHTML page or adding it to one of the pages in the Layouts section?

I know I can call this within a plugin but that’s not what I am looking to do. When I try calling it from the customHTML section or a layout page it says: TypeError: Cannot read property ‘setMacroJsOverride’ of undefined.

Is this something that is just not possible or is there another JS call that does something similar that can be used outside a plugin?

I call it from Custom Html within Confluence. In my instance, I am customizing the options the Bob Swift SQL macro presents to users.

	AJS.bind("init.rte", function() {
		AJS.MacroBrowser.setMacroJsOverride('sql', {
			"fields": {
				"string": function(param, options){
					var dataSource = AJS.$("#macro-param-dataSource");
					if ('select2')) {

						containerCssClass: " aui-select2-container",
						dropdownCssClass: " aui-select2-drop aui-dropdown2 aui-style-default",
						minimumResultsForSearch: -1,
						data: data,
						initSelection: function(element, callback) {
								var value = element[0].value;
								if (value !== "") {
							}, 500);

Ahh so the part I was missing is the “AJS.bind(“init.rte”, function() {})”. Thanks a lot for your help.

1 Like

Happy to share. Please do be aware, you want to make sure you wait for document.ready (AJS.toInit(function(){}) as well as bind to the init.rte event. I ran into issues if I did not include both in this order, but i didn’t investigate it further. Just found what worked and proceeded.

Issue was I did have that toInit() function but I was missing the binding to init.rte. Once I realized I was missing that when looking at your answer, I added it and it started working as expected. Thanks

1 Like