Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

User macro to validate last modified date of confluence page

Nallusamy Narayanaswamy
Contributor
November 12, 2021

Hi

I want to create a user macro which will validate whether last modified date is greater than given timeframe. 

If current date - last modified date >= 30 days, need to populate a waring message saying "The page needs to be reviewed as It was last modified 30 days ago" 

 

Also, I want to set this day (30 days) to be dynamic. User should able to set their own timeframe when they adding the macro to their page. 

 

Is it possible to have such a user macro that accept dynamic parameter? Can someone pls help?

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2021

This is not quite what user macros do, they don't "validate" or process things, they run when a page is rendered.

Now, that does not mean you can't get them to do things (you could write a macro that updates a counter somewhere every time a page is viewed for example, or trigger a script or javascript if they rendered a clickable button) but mostly they are used for rendering things, not doing things.  Rendering stuff is a lot easier than making them process things (and quite often people don't get that processing stuff on view is usually a bad idea as it can end up being done way too many times!)

So, I want to redefine your macro a little bit, and check that my definition would do what you want.  Given that your people would use the macro with something simple like

{update-needed: parameter X}

Then when the macro is added to a page, when rendered, it will do something like:

  • If ( Updated date < Today - X days)
    • Display a nice big warning panel saying "This page needs to be reviewed as It was last modified over X days ago"
  • else
    • Display nothing
  • fi

Would that be the right behaviour?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events