Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automatic insertion of a static text into a page title

Edited

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.

1 answer

0 votes
Bill Bailey Community Leader Jan 13, 2022

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.

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

Bill Bailey Community Leader Jan 13, 2022

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))

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.

Bill Bailey Community Leader Jan 14, 2022

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:

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

Thank you!
I will give a try these templates later.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

4,772 views 10 52
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you