Automatic insertion of a static text into a page title
Asked by wl2776:

Every Friday I write a weekly report in our Confluence.

To do it, I create a new page, entitled "Week 2 (10.01.2022 - 14.01.2022)", then I fill a week summary. Dates are Monday and Friday of the respective week.

I am looking for a way to automatically insert a text containing week number and dates of Monday and Friday.

Our Confluence admin has created user macros for me, that calculate these values. And I have created a page template with them.

As far as I know these macros are written in Javascript, they query OS about current time and calculate week number and dates of Monday and Friday from it.

I have sent links to JS code snippets to our admin.

I can also access these macros from the page editor menu by clicking Plus sign -\> Macro.

However, there are two issues

1. It is not possible to insert them into page title, only in the body.

2. These macros are always invoked, changing content of pages. If I visit some past report, I see current week number and dates of Monday and Friday on current week, not from the past.


Answers:
author: Bill Bailey
body: I would suggest updating the user macros to either:

1. Allow you to set the start date
2. Trigger off the creation date of the page (very easy).

That will get you part of the way there.

comments: author: wl2776
body: Could you elaborate?

I've got 3 user macros, that query current time from the OS and calculate week number, date of Monday and date of Friday.

How should he change them?

I've added details to the question


author: Bill Bailey
body: Did you write the macros? Because it is possible to query the creation date of the page, and then use that value to calculate what you need, rather than from OS. Since you create the page every Friday, you can use that as a static point in time that never changes.

For example, something like

```
#set($currentPage = $pageManager.getPage($content.id))
#set($dateInfo=$action.dateFormatter.formatGivenString("yyyy-MM-dd", $currentPage.creationDate))
```


author: wl2776
body: No, I don't have admin privileges. I only have access to content tools of one space.

I have sent our admin following link and asked if it is possible to have similar function in the Confluence.

<https://github.com/nattoheaven/macrotemplate/blob/9e64f527239fec5e9de18dc797a2c240ad719b73/bootstrap.js#L33>

After some time he has created macros that I can see as "Get current Monday" and "Get current Friday."

He has also said that it is not possible to put these macros into the page title. Now I see. This because they are invoked always, and page title will always change making impossible getting pages by title.

So, I have created a page template, containing these macros in the body.

When I create a new page from that template, I click on "Preview", copy generated text, then click on "Edit", remove macros and paste that text instead.

That's tedious and unprofessional.

And I don't always create reports on Fridays. Yes, most of weekly reports are created on Fridays, but not always.

Indeed, using page creation date is a way to go, if it doesn't change after modifications.

The question with automatic filling of the title still remains.


author: Bill Bailey
body: The auto title creation would be hard, but the creation date remains the creation date. So that change they can make.

Have you looked at either of these two templates:

* <https://confluence.atlassian.com/doc/meeting-notes-blueprint-329975386.html>
* <https://www.atlassian.com/software/confluence/templates/weekly-meeting-notes>

I know the first one can be modified. Maybe the second can as well?


author: wl2776
body: Thank you!  
I will give a try these templates later.


author: wl2776
body: I was unable to find the second plugin (weekly meeting notes) in the Atlassian Marketplace to ask our Confluence administrator to install it.

I mean, I open Confluence, then choose "Marketplace" in the top-right menu, and the Marketplace opens. However, search for "weekly meeting notes" in that marketplace doesn't show anything.

About the first one, Meeting Notes Blueprint.

If I click on "Create a new page" and choose "Meeting notes" in the list of templates that Confluence shows me, then I get a page with today's date in the title, for example 2022-02-04 Meeting notes.

I've tried to modify it, but nothing in the page shows how that date was inserted.

When I open Space Tools, find that blueprint and click on Edit, a page contains just a static text in the title, no macros or function calls, suggesting that a date will be prepended to that static text. Nothing to work with.

That blueprint also contains a strange object "$currentDateLozenge". Google haven't brought me anything useful about that object.

Probably, the way to go is creation of my own blueprint <https://developer.atlassian.com/server/confluence/confluence-blueprints/>

Another variant is to create a simple python script that would generate a new page with required contents.


Tags: confluence-server

server