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
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
Writing User Macros
Now for us to achieve this result, we will need to:
1- Click the Cog Icon at the top right corner in Confluence2- Select General Configuration3- Search for User Macros in the left side bar4- Enter User Macros5- 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 simplicity2- Select who can view this macro under Visibility3- Write a Macro Title for this macro. Macro title is what is shown when you search for this macro4- Under Definition of User Macro, look into Macro Body processing5- Select No Macro Body6- 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
1- In the Macro name text field, insert a name for this macro. I used creator-macro, for the sake of simplicity2- Select who can view this macro under Visibility3- Write a Macro Title for this macro. Macro title is what is shown when you search for this macro4- Under Definition of User Macro, look into Macro Body processing5- Select No Macro Body6- 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>
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
Hello @Diego
It seems the user @Gilbert Louis is using Confluence cloud, thus I don't think "User macros" are possible on the confluence cloud.
https://confluence.atlassian.com/confcloud/restricted-functions-in-confluence-cloud-734070955.html
@Tarun Sapra, @Diego 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
It looks like you're new here. Sign in or register to get started.