auto-populating the currentuser name and today's date when creating a new from from a template
Asked by Gilbert Louis:

Hi,

Creating my first space template and I'm looking to minimize input fields and so I am looking to automatically populate the 'Requested by' field by the currentusername (registered name of the user creating that new document) AND the created date (today) when a user is creating a new document from that specific template.

Thx for your help


Answers:
author: Diego
body: Hello there Gilbert!  
You can surely achieve this with **native tools from Confluence** . However, we will need to dig a little into **User Macros creation** .   

Let us start by taking a look here:

**[Macro Template Syntax](https://confluence.atlassian.com/doc/user-macro-template-syntax-223906130.html)**

**[Writing User Macros](https://confluence.atlassian.com/doc/writing-user-macros-4485.html)**

Now for us to achieve this result, we will need to:
> 1- Click the **Cog Icon** at the **top right corner** in Confluence  
> 2- Select **General Configuration**   
> 3- Search for **User Macros** in the left side bar  
> 4- Enter **User Macros**   
> 5- Click to **Create a User Macro**

Now that we are inside the creation, we can start creating the macro:
> 1- In the **Macro name** text field, **insert a name** for this macro. I used **creator-macro** , for the sake of simplicity  
> 2- Select **who can view** this macro under **Visibility**   
> 3- Write a **Macro Title** for this macro. Macro title is what **is shown when you search** for this macro  
> 4- Under **Definition of User Macro** , look into **Macro Body processing**   
> 5- Select **No Macro Body**   
> 6- Now in the **Template** text field, insert **this code** for the macro
>
> ```
> ## @noparams
>
> <div class="aui-message aui-message-info">
> $content.getCreatorName()
> $action.dateFormatter.formatGivenString("yyyy-MM-dd", $content.getCreationDate()) 
> </div>
> ```
>
> 7- **Save** the macro  
>
After saving, you can now **create your template** and insert this new macro into it. When someone uses the template, their name and content creation date should be displayed.

Let us know if this is what you are looking for!

edit: fixed the user macro

comments: author: Tarun Sapra
body: Hello [@Diego](/t5/user/viewprofilepage/user-id/1188952)

It seems the user [@Gilbert Louis](/t5/user/viewprofilepage/user-id/1458395) is using Confluence cloud, thus I don't think "User macros" are possible on the confluence cloud.


author: Tarun Sapra
body: [https://confluence.atlassian.com/confcloud/restricted-functions-in-confluence-cloud-734070955.html](https://confluence.atlassian.com/confcloud/restricted-functions-in-confluence-cloud-734070955.html?_ga=2.69602832.122622044.1546420893-1359772982.1527518782)


author: Gilbert Louis
body: [@Tarun Sapra](/t5/user/viewprofilepage/user-id/781576), [@Diego](/t5/user/viewprofilepage/user-id/1188952) yes we are using confluence cloud.

I have access to the general configuration pages but can only see 'macro usage' option in that list on the left hand side.

I would be surprised that something as 'simple' as fetching the user name to auto-populate it in a user created template is not available in confluence cloud???

or same to fetch today's date to add to my template so I know when that page was created.

Thx

Gilbert


author: Diego
body: Hello there!

Thanks for pointing that out. I did not notice the **tag for Confluence Clou**d. I have synced with my Confluence Cloud colleagues about this request and currently, we can not achieve this in Confluence Cloud.

You can surely check this info under **Three dots menu (..)\>Page Information**. A third-party solution does exist, but is only available for Confluence Server as well:

**[Page Info for ScriptRunner Confluence](https://marketplace.atlassian.com/apps/174/page-info-for-scriptrunner-confluence?hosting=server&tab=overview)**

Also, let me fix my user macro sent before. Currently, this would show the **current user**, not the creator. Fixed version is as follows:

```
## @noparams

<div class="aui-message aui-message-info">
$content.getCreatorName()
$action.dateFormatter.formatGivenString("yyyy-MM-dd", $content.getCreationDate()) 
</div>
```

Let us know your thoughts!


author: Gilbert Louis
body: [@Diego](/t5/user/viewprofilepage/user-id/1188952)Much appreciate your time and effort to provide an answer... I will look at implementing in the morning and will let u know... :-)


author: James Dellow
body: User macros aren't possible in Confluence Cloud, but you can create your own macros (and other functionality) as Confluence Connect apps. The simplest app to create could just be some templated wiki content, accessed as a custom macro (just like a user macro).

More here <https://developer.atlassian.com/cloud/confluence/about-confluence-cloud/>


author: Diego
body: Hello there [@Gilbert Louis](/t5/user/viewprofilepage/user-id/1458395)!

As pointed out earlier by Champions here, this solution is **not available for Confluence Cloud**. The solution provided took in consideration Confluence Server, which is not the correct environment. It may be a good idea to take a look into this article:

**[Functional differences in Confluence Cloud](https://confluence.atlassian.com/confcloud/restricted-functions-in-confluence-cloud-734070955.html)**

You can still check this information under **Three dots menu (..)\>Page Information**. There you should be able to check all those details.


Tags: cloud

confluence-cloud