I have a master page and a child page.
In the master page I have a page property macro with several properties.
In the child page I want to copy a specific property.
I have found that there is an API call like this:
/rest/masterdetail/1.0/detailssummary/lines?cql=id=25807045&spaceKey=XXXX&headings=Conclusie&pageIndex=0"
When called in the browser I get the correct result, namely the value of the property "Conclusie".
I'm struggling to use this in a user macro.
This is what I have sofar:
## @noparams
<script type="text/javascript">
AJS.$.ajax({
url: "/rest/masterdetail/1.0/detailssummary/lines?cql=id=25807045&spaceKey=XXXX&headings=Conclusie&pageIndex=0",
contentType: 'application/json',
type: "GET",
success: function(msg){
alert(msg);
}
</script>
I get a rendering error.
Error occurred rendering template content
Would appreciate any hints or suggestions.
TIA
## Remarks: properties with space in the name cause problems
## https://stackoverflow.com/questions/6802765/jquery-dealing-with-a-space-in-the-id-attribute
## not allowing page properties with spaces in it solves it at the source, but you want labels with spaces
## $prop.replace(" ", "")) solved it
## @Param PropertyName:title=Property|type=string|desc=Name of the page property of the parent page|Required=true
#set ($parentID = $content.getParent().getIdAsString())
#set ($prop = "$paramPropertyName")
#set ($propid = $prop.replace(" ", ""))
<div id="$propid"></div>
<script type="text/javascript">
jQuery.ajax({
url: "/rest/masterdetail/1.0/detailssummary/lines?cql=id=$parentID&spaceKey=ISMS&headings=$prop&pageIndex=0",
contentType: 'application/json',
dataType: 'json',
type: "GET",
success: function(data){
var props = data;
property = props.detailLines[0].details[0];
$("div[id=$propid]").html(property);
},
});
</script>
Hello there @Peter Florijn !
I can assist you a little with the issue that you are currently facing. The rendering issue you are seeing is probably due to this line here:
AJS.$.ajax({
Try swapping it with this:
jQuery.ajax({
Also, it seems that we are missing a few brackets. Here is what it would look like with those placed and jQuery.ajax replacing AJS.$ajax:
## @noparams
<script type="text/javascript">
jQuery.ajax({
url: "/rest/masterdetail/1.0/detailssummary/lines?cql=id=327708&spaceKey=DEM&headings=00&pageIndex=0",
contentType: 'application/json',
type: "GET",
success: function(msg){
alert(msg);
},
});
</script>
For further assistance on how to use JavaScript within Confluence, you can refer to our documentation:
Or even reach out to our Developer Community, here:
Let us hear from you, Peter!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Peter! Thanks for coming back to the thread. Glad to read that my reply helped you find the solution.
Come share with the community (or the Developer Community!) some time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
I don't have the skills to analyse your User Macro, but I'd simply put an Excerpt Macro in the table cell of the desired page property on the parent page and display it on the child page with the Excerpt Include Macro - of course, this won't work when you use the Excerpt Macro for another purpose...
Best regards,
Nicolai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Nicolai Sibler
Thanks for your reply. I also considered Excerpt macro, but this is not feasibile because I have a lot of different Master (source) pages.
So I need a more dynamic approach.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.