# Is there an onCopy JS-Function to detect if a macro is copied or created?

**URL:** <https://community.developer.atlassian.com/t/is-there-an-oncopy-js-function-to-detect-if-a-macro-is-copied-or-created/63383>\
**Category:** Confluence Development\
**Created:** [November 11, 2022, 8:04am UTC](https://community.developer.atlassian.com/t/is-there-an-oncopy-js-function-to-detect-if-a-macro-is-copied-or-created/63383 "2022-11-11T08:04:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RainerEmil](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@RainerEmil](https://community.developer.atlassian.com/u/RainerEmil)\
**Post date:** [November 11, 2022, 8:04am UTC](https://community.developer.atlassian.com/t/is-there-an-oncopy-js-function-to-detect-if-a-macro-is-copied-or-created/63383/1 "2022-11-11T08:04:54Z")

</div>

I want to detect, if a user creates a macro or copy&paste it e.g. for changing a parameter.

The PSEUDOCODE below explain what I want to do by changing the parameter named “id”:

```auto
My Idea is to use “setMacroJsOverride()” in the resource file “my.js”

AJS.MacroBrowser.setMacroJsOverride("mymacro", {
   /* add "onCopy() Listener here*/ : 
           function (param) {
               var parameterField = AJS.MacroBrowser.ParameterFields["string"](/* Parameter ID. Is there a "getParamByName() "?*/, {});

               parameterField.setValue(parameterField.getValue+"-copy");

               return /* what ever ? */;
            }
});

```

Can someone help to replace the comments to turn the pseudocode into for working code?

Best Regards  
Rainer
