How to find broken macros including specific space key?
Asked by ryder:

Hello,

we are using a confluence cloud instance and have to spaces.

One of theses spaces must be copied and will get a new space key.

The other space uses macros like "include page" and in the macro configuration is the space key used to link the right page. Now, when the space key will be changed, how can I find the pages where macros like include page, excerpt etc. are used and are now broken?

Any hints?

Wishes

Thorsten


Answers:
author: Dominic Lagger
body: Hi [@ryder](/t5/user/viewprofilepage/user-id/1243697)

There are two options:

1. Go to the confluence settings and choose "Macro Usage". There you can click on the macro and you will be redirected to the search.   
   https://\<\<yourinstance\>\>.atlassian.net/wiki/admin/pluginusage.action
2. Go to the search and type:

   ```
   macroName:excerpt-include*
   ```

   https://\<\<yourinstance\>\>.atlassian.net/wiki/dosearchsite.action?cql=siteSearch+\~+%22macroName%3Aexcerpt-include\*%22

Hope this helps

Regards, Dominic

comments: author: ryder
body: [@Dominic Lagger](/t5/user/viewprofilepage/user-id/601600)

I'm not sure, if I get this right.

I have plenty uses of e.g. excerpt-include. When I use excerpt-include it might be possible that the macro hat a space key konfigured for getting the right page.

So I want all page which uses excerpt-include referencing to page using the space key ABCD.

I did not understand in your example to shrink the search in uses of excerpt-include which includes the space key ABCD?

Is this anyhow possible?

Thanks, in advanced.

ciao

Thorsten


author: Dominic Lagger
body: oh okay, you want also to search the parameters of the macro.

I found an article on the web and tried it. It works, but I get too much search results...

* [How to search for macros and macro parameters in Confluence](https://ffeathers.wordpress.com/2012/09/04/how-to-search-for-macros-and-macro-parameters-in-confluence-4/)

In confluence 4, there was the possibility to search with "wikimarkup" terms. This looked like this:

```
wikiMarkup:"excerpt-include:Introduction to chocolate"
```

This searches all the "excerpt-include" macros with a connection to the page "Introduction to chocolate"

For your case, it must be

```
wikiMarkup:"excerpt-include:SPACEKEY"
```

But as I said, I got to much results, even results, without having an excerpt-include macro.

Do you have access to the database? Perhaps there you could make an SQL:

```
select * from content, bodycontent where bodycontent.contentId = content.contentId and body like '%excerpt-include:SPACEKEY%'
```

Regards, Dominic


author: ryder
body: [@Dominic Lagger](/t5/user/viewprofilepage/user-id/601600) ,

yes, I have the same problem, I see also pages without the macro.

And no, I do not have SQL access. Only CLI. But I did not find a solution using CLI and I did not find a solution using wikimarkup search terms. This was the reason for this post.

Regards,

Thorsten


author: Michael Kuhl _Appfire_
body: Hi [@ryder](/t5/user/viewprofilepage/user-id/1243697) - You mentioned you have the CLI. I assume you are referring to the [Bob Swift Confluence CLI](https://marketplace.atlassian.com/284).

If so, you can solve this problem in one action using the [copySpace](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/1059405776/copySpace) action with the findReplace option. Here's an example of how you might do this:

```
acli --action copySpace --space "OLDSPACEKEY" --newSpace "NEWSPACEKEY" --findReplace "OLDSPACEKEY:NEWSPACEKEY"
```

This action will copy of all of the content from OLDSPACE to NEWSPACE, replacing the space keys in the page content in the process.

By the way: I'm the product manager for the Bob Swift CLI product line.


author: ryder
body: Hi Michael,

thanks for your answer. It works, really great. It takes some time and need some extra copying, but it works fantastic!

Regards,

Thorsten


Tags: cloud