Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

User Macro to set page properties no longer working in Confluence 7.4

Hello I have a relatively simple user macro to set some page properties, sadly it stoped working whith the upgrade to Confluence 7.4 and the macro test is just displayed on the confluence page without being evaluated at all. Maybe anyone here has an idea what changed from confluence 6.15 to 7.4 that can break this code so badly... :/

## Macro title: 
## Macro has a body: Y
## Body processing: None
## Output: None
## Developed by: Moritz Wagner
## Date created: dd/mm/yyyy
## Installed by: My Name
## @param Template:title=Template|type=string|required=true|desc=The template this document is based on
## @param Version:title=Template version|type=string|required=true|desc=The Version of this Template
## @param Valid:title=Template valid since|type=date|required=true|desc=The date since this template version is valid

#set ( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set ( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set ( $containerManager=$getInstanceMethod.invoke(null,null) )
#set ( $containerContext=$containerManager.containerContext )
#set ( $contentPropertyManager=$containerContext.getComponent('contentPropertyManager') )

$contentPropertyManager.setTextProperty($content, "templateInfo.title", $paramTemplate)
$contentPropertyManager.setTextProperty($content, "templateInfo.version", $paramVersion)
$contentPropertyManager.setTextProperty($content, "templateInfo.valid", $paramValid)
$contentPropertyManager.setTextProperty($content, "templateInfo.ticketNb", $body)

 


Thanks very much in advance,

 

Moritz

1 answer

1 accepted

0 votes
Answer accepted
Dominic Lagger Community Leader Oct 19, 2020

Hi  @Moritz Wagner 

I had the same issue and found some helpful information in the developer community:

You can use the $content.getProperties() and don't have to use the ContentPropertyManager anymore. 

#set ( $props = $content.getProperties() )
#set ( $newProps = $props.setStringProperty("templateInfo.title", $paramTemplate) )

Regards, Dominic

Thank you Dominic, I'm also having this problem however I believe Moritz and I are using: 

setTextProperty

Not: 

setStringProperty

So this solution doesn't appear to work (at least for me). I'm unable to access the data previously saved with the ContentPropertyManager and the setTextProperty method.

Any chance you have any other suggestions or could point us in another direction?

Hello Dominic,

Hi Blake,

for me the supposed version works flawless, thank you so much for this quick fix, that saved me hours of searching!! 

 

Have a good Day,

Moritz

Dominic Lagger Community Leader Oct 21, 2020

hi @Blake Manosh 

What error do you get and what confluence version do you use?

I would have said that it does not matter if you take string or text. You just have to take always the same :)

With 

$content.getProperties()

you will get a "ContentProperties" Class.

There you can use getTextProperty or getStringProperty.

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.4
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

156 views 0 5
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