User Macro to set page properties no longer working in Confluence 7.4
Asked by Moritz Wagner:

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)

```

<br />

Thanks very much in advance,

Moritz


Answers:
author: Dominic Lagger
body: Hi [@Moritz Wagner](/t5/user/viewprofilepage/user-id/3579687)

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

* [Cant use contentpropertymanager anymore in user macro since 7.0.3](https://community.developer.atlassian.com/t/cant-use-contentpropertymanager-anymore-in-user-macro-since-7-0-3/32956/4)
* or even here in the community: [Community Post](https://community.atlassian.com/t5/Confluence-questions/can-t-use-contentPropertyManager-anymore-in-user-macro-since-7-0/qaq-p/1212198)

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

comments: author: Blake Manosh
body: 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?


author: Moritz Wagner
body: 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


author: Dominic Lagger
body: hi [@Blake Manosh](/t5/user/viewprofilepage/user-id/1228657)

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](https://docs.atlassian.com/ConfluenceServer/javadoc/7.8.1/com/atlassian/confluence/content/ContentProperties.html)" Class.

There you can use getTextProperty or getStringProperty.

Regards, Dominic


Tags: confluence-server

page-property

server

user-macro