# Documentation for AJS.MacroBrowser.setMacroJsOverride

**URL:** <https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746>\
**Category:** Confluence Server\
**Tags:** macrobrowser, macro, confluence-server\
**Created:** [July 12, 2021, 3:10am UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746 "2021-07-12T03:10:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChongJingHong](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@ChongJingHong](https://community.developer.atlassian.com/u/ChongJingHong)\
**Post date:** [July 12, 2021, 3:10am UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746/1 "2021-07-12T03:10:04Z")

</div>

Is there a documentation for AJS.MacroBrowser.setMacroJsOverride? I want to create a custom dialog for my macro plugin.

---

<div class="post-metadata">

**Author:** ![aknight](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@aknight](https://community.developer.atlassian.com/u/aknight)\
**Post date:** [July 14, 2021, 3:47am UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746/2 "2021-07-14T03:47:03Z")

</div>

Hi @ChongJingHong ,  
We don’t have official public documentation for `MacroJsOverrides` as far as I’m aware. However I’m more than happy to answer any questions about specific override functionality.

If you want to create an entirely custom dialog, you will have to override the `opener` function.

If the `opener` override is present, the `macro browser` will call the custom `opener` function rather than the default. You will then have to do all the work of rendering an `AUI dialog` containing the content of the macro editor, including all of the parameter inputs fields, a save button and ideally a previewer. Then once the user clicks the save button, you can call `tinymce.confluence.macrobrowser.macroBrowserComplete` with an object containing the macro parameter data to be stored on the page.

E.g.

```auto
AJS.toInit(function () {
    AJS.MacroBrowser.setMacroJsOverride('macroName', { opener: function (macro) {
        // add dialog2 to DOM and show dialog
       submitButton.addEventListener('click', function(e) {
            // Collect all user inputted macro data
            tinymce.confluence.macrobrowser.macroBrowserComplete({name: 'macroName', params: macroData})
       });
   });
});

```

If you don’t need to override the entire macro editor dialog, a subset of the other supported macro overrides are:

Customise macro input fields

- `field` override to customise the specific field input elements

Callbacks to modify the raw macro data input by the user:

- `manipulateMarkup` - called once the macro editor form submit has been clicked. Called with the entire macro editor metadata including the parameters before the parameters are extracted from the form.
- `beforeParamsRetrieved` - called after `manipulateMarkup` with the final macro parameters right before `macroBrowserComplete` is called.

Callback when previewing the macro:

- `postPreview` - called with the preview iframe element and macro metadata when the user previews the macro

We also have callbacks for when an existing macro is being edited

- `updateSelectedMacro` - called with the macro object
- `getMacroDetailsFromSelectedMacro` - called with the macro metadata

---

<div class="post-metadata">

**Author:** ![ChongJingHong](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@ChongJingHong](https://community.developer.atlassian.com/u/ChongJingHong)\
**Post date:** [July 14, 2021, 4:20am UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746/3 "2021-07-14T04:20:58Z")

</div>

@aknight Omg thank you so much for taking the time to write these information down.

If I want a parameter to be able to input multiple lines, I could just use the `field` override to change the input to a `<textarea>`?

Is this right?

```auto
AJS.toInit(function(){
    AJS.MacroBrowser.setMacroJsOverride('macroName', {
        'field' : {
            'string' : function(param, options){
                var myParam = AJS.$('#id-of-parameter');
                var myParamParent = AJS.$('#id-of-parent-element');
                myParam.remove();

                var newParam = document.createElement("textarea");
                newParam.setAttribute('id', '#id-of-parameter');

                myParamParent.append(newParam);
            }
        }
    })
})

```

---

<div class="post-metadata">

**Author:** ![TatjanaArangjelova](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@TatjanaArangjelova](https://community.developer.atlassian.com/u/TatjanaArangjelova)\
**Post date:** [March 3, 2023, 3:34pm UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746/4 "2023-03-03T15:34:01Z")

</div>

Hi @aknight

I want to disable the insert/save button (Insert ) on the macro dialog if user enter invalid parameter .  
Can I use this method for this purpose?

---

<div class="post-metadata">

**Author:** ![mr.chris.kent](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mr.chris.kent](https://community.developer.atlassian.com/u/mr.chris.kent)\
**Post date:** [August 7, 2024, 2:28am UTC](https://community.developer.atlassian.com/t/documentation-for-ajs-macrobrowser-setmacrojsoverride/49746/5 "2024-08-07T02:28:23Z")

</div>

Hi @ChongJingHong ,

I am trying to get a macro to use the param type “attachment”.  
There is nothing I can find on how to get this param type to work.  
A few hits on searches suggest using this code.  
AJS.MacroBrowser.activateSmartFieldsAttachmentsOnPage(“macro-name”, [list of extensions]);  
I have tried and failed.  
Is there any sample code that I can use to get this working?
