why does Create from Template Macro open create dialogue instead of target template? [SOLVED]
Asked by Olaf Eichst?dt:

I start to edit a page, add the Create from Template Macro, configure the macro for one of the templates in the drop down list, save the page, click the button ... and the "Create ..." dialogue appears and asks me to select a template.   

Why would the Macro default to the "Create ..."-dialogue instead of using the template specified in the macros drop down menu?

Short answer as of 2019-11-21: **don't use "0" as a space key in CONFLUENCE.**


Answers:
author: Olaf Eichst?dt
body: > Is that right?  
> Does this occur with any template or with specific ones?

Your recap sounds about right. I did some digging and found that it sometimes works and sometimes not. And there are some funny things going on that I cannot explain.  

I "inspected" working and non working buttons with the following result:

This button **works**:

```
<a class="aui-button create-from-template-button conf-macro output-inline" data-space-key="2" href="http://www.OURURL.cn:8090?createDialogSpaceKey=2&amp;createDialogBlueprintId=cd9d173b-2cb7-4324-90f5-a352aa637b2d" data-content-blueprint-id="cd9d173b-2cb7-4324-90f5-a352aa637b2d" data-hasbody="false" data-macro-name="create-from-template">??????</a>
```

This button **works**:

```
<a class="aui-button create-from-template-button conf-macro output-inline" data-space-key="office" href="http://www.OURURL.cn:8090?templateId=2293781&amp;spaceKey=office&amp;newSpaceKey=office" data-template-id="2293781" data-hasbody="false" data-macro-name="create-from-template">Create from template</a>
```

This button **works**:

```
<a class="aui-button create-from-template-button conf-macro output-inline" data-space-key="office" href="http://www.OURURL.cn:8090?templateId=2293781&amp;spaceKey=office&amp;newSpaceKey=office" data-template-id="2293781" data-hasbody="false" data-macro-name="create-from-template">Create from template</a>
```

This button **FAILS** as described in the original question:

```
<a class="aui-button create-from-template-button conf-macro output-inline" data-space-key="0" href="http://www.OURURL.cn:8090?templateId=2293781&amp;spaceKey=0&amp;newSpaceKey=0" data-template-id="2293781" data-hasbody="false" data-macro-name="create-from-template">Create from template</a>
```

Please note that there are 2 different templates (first example uses standard meeting notes templates), examples 2-4 is a customized template.

**I find it suspicious that the only FAILING buttons I could create so far reside in a space with space key="0" (data-space-key="0").**

Funny things that happen:

(1) if I ask one of the working buttons to open the standard CALENDAR template (the first one in my list), I get a stalling dialogue window (never ending rotating ring indicator) after the first click of the button, and a working calendar dialogue after cancel and the second click on the same button.  

(2) I had some buttons ... I believe it was the button on the original meeting index page ... that said it would use the Calendar template when I edited it ... but in fact it opened the meeting notes template. However, I can no longer recreate that. When I create a button myself, I get the "funny" case No 1.

comments: author: Shannon S
body: Hello Olaf,

Thank you for those details.

Can you try to first [reindex Confluence from scratch](https://confluence.atlassian.com/confkb/how-to-rebuild-the-content-indexes-from-scratch-on-confluence-server-110035351.html) and let me know if it corrects the problem?

It is very odd that it has 2 and 0 as the name of the space key. Can you show me what you put for the macro variables when creating the button for both the working ones and the one that's not working?

As for the Calendar template issue, it might not be related. Could you tail your Confluence logs and see what errors occur when the creation window is spinning?

Regards,

Shannon


author: Olaf Eichst?dt
body: I have limited access to the server, would need to ask the server admin to get access to the console .... but I rebuilt the index from within Confluence admin pages =\> no change

The space keys "2" and "0" where assigned to spaces "2"="200 some name" and "0"="000 some other name". The numbers where added to the names in order to create a defined sort order in the space directory. Because the numbers are the first character of the space name, and confluence seems to automatically pick them as space key, I did not find it strange at all.

Just to make sure: space key="2" works as expected. Only space key = "0" fails. Is it possible that some code "thinks" that space key ="0" is a none-existing key? I have faint recollection of some coding errors where implicit type conversion turned a "0" string into something that was interpreted as "false" ... but I cannot recall the details now.


author: Olaf Eichst?dt
body: regarding the Calendar template: please advise how/where I can find the logs


author: Shannon S
body: Hello Olaf,

I've tested this on my own instance running 7.0.4, and the only time I am able to replicate this issue is when it's for a space key that's just the number 0.

If I try to create a space called "000 some other name" as a test, the space key was automatically assigned as 0S and it worked properly. Only if I set the space key to 0 does it break.

I created a bug ticket for this:

* [CONFSERVER-59100](https://jira.atlassian.com/browse/CONFSERVER-59100) *Create from Template macro does not use specified macro parameters when space key is set to '0'*

From your description earlier you said the code "thinks" that the space key is 0. Can you confirm if that means the space key is actually something other than 0? Are you able to have the server administrator check the database to see if this is the case?

In order to obtain your server logs to see details about the Team Calendar issue, you can find the logs from the server directly: [Working with Confluence Logs](https://confluence.atlassian.com/doc/working-with-confluence-logs-108364721.html)

To proceed further in this case, the results we will be asking you for will require Confluence server administrator access, so you may want to consider having your admin raise a ticket with support or join in on this request.

Regards,

Shannon


author: Olaf Eichst?dt
body: ![spacekey_zero.png](https://community.atlassian.com/t5/image/serverpage/image-id/72507iE097DE73132B0593/image-size/large?v=v2&px=999 "spacekey_zero.png")


author: Olaf Eichst?dt
body: I must admit that I do not recall how the space key became "0" ... but it is, see above screenshot


author: Shannon S
body: Hello Olaf,

Thank you for providing that screenshot.

I understand what happened here. When you go to create a new space, Confluence will automatically suggest a space key based on that Latin characters you enter into the Space Name.

So in general "000 Space Name Here" might select the space key 0S. In your case, the rest of the space name is in Chinese, so Confluence doesn't recognize any characters besides the first 000.

See the same here when I try in Japanese:

![CleanShot 2019-11-12 at 13.40.12.png](https://community.atlassian.com/t5/image/serverpage/image-id/72587i15E36AF104A0D9FC/image-size/large?v=v2&px=999 "CleanShot 2019-11-12 at 13.40.12.png")

To fix this, you'll need to make a copy of the space with a new space key. See [How to Copy or Rename a Space in Confluence](https://confluence.atlassian.com/confkb/how-to-copy-or-rename-a-space-in-confluence-169578.html). You just need to ensure that you do not use the same space key as before.

Let me know if you have any trouble with this.

Regards,

Shannon


author: Olaf Eichst?dt
body: Thanks for the feedback ... that explains where the simple "0"-only space key came from. Another nice example of inter-cultural communication problems when east meets latin ;-)   

I created a new space, set the space key manually to something else than "0"and moved all content to the new space. There was not too much of it yet and I got away by moving the "home page" (and its children) to the newly created space and making it the new home page.

We will see when issue [CONFSERVER-59100](https://jira.atlassian.com/browse/CONFSERVER-59100) will bubble from the backlog to the surface. It has been classified as minor and placed in the long term backlog. I guess that "0"-only space keys are quite rare.


author: Shannon S
body: Hello Olaf,

Glad to hear you were able to migrate to the new space.

As for the issue, it's currently "minor" because I just created the bug and it hasn't been prioritized by the team yet. If you watch it, you'll receive an update if it's been reprioritized.

Take care, and have a pleasant rest of your week.

Regards,

Shannon


author: Shannon S
body: Hello Olaf,

Thank you for reporting this to us. From what I understand, you've already selected which template the macro should use, but when you use the button, it asks you to select a new template. Is that right? Does this occur with any template or with specific ones?

Can you let me know what version of Confluence you're using? I want to see if I can replicate the issue.

Regards,

Shannon

comments: author: Olaf Eichst?dt
body: Powered by Atlassian Confluence 6.15.4


Tags: confluence-server