Forums

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

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

Moritz Wagner
Contributor
October 19, 2020

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
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.
October 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

Blake Manosh October 20, 2020

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?

Moritz Wagner
Contributor
October 21, 2020

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
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.
October 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
AUG Leaders

Atlassian Community Events