Problem with accessing context params (like space.id) when building static macro plugin

I’m building static macro and in macro editor URL I’m not able to put context params like space.id or page.id. So this will not work:

  "editor": {
         "url": "/macro/editor?&spaceId={space.id}",
         "editTitle": {
           "value": "Edit Dynamic macro"
         },
         "insertTitle": {
           "value": "Insert Dynamic macro"
         }
       },

Why? :slight_smile: Is there are any other methods to get the spaceId?
I’m trying also inside the macro editor to call AP.context.getContext() but I’m also getting empty object.:confused:

Regards,
Richard

1 Like

@RichardHamilton - can you send your full descriptor? space.id and page.id are coming up fine in both static and dynamic content macros for me.

    "staticContentMacros": [{
      "url": "/rest/static-content?macroId={macro.id}&templateId={templateId}&pageId={page.id}&pageVersion={page.version}",
      "description": {
        "value": ""
      },
      "documentation": {
        "url" : "http://www.google.com"
      },
      "aliases": ["template"],
      "editor": {
        "url": "/macro/editor?&spaceId={space.id}",
        "editTitle": {
          "value": "Edit Static macro"
        },
        "insertTitle": {
          "value": "Insert Static macro"
        }
      },
      "categories": ["confluence-content"],
      "outputType": "block",
      "bodyType": "none",
      "name": {
        "value": "Static Content (Connect)"
      },
      "key": "static-content-macro",
      "parameters": [{
        "identifier": "templateId",
        "name": {
          "value": "Template Id"
        },
        "type": "string",
        "required": true,
        "multiple": false
      }]
    }]

In “url” those contextual params are working but not in “url” under the “editor” element

1 Like

@RichardHamilton, unfortunately, context parameters are not available in the Macro Editor module url; however, you can use the Navigator API in JS.

AP.navigator.getLocation(function (location) {
  console.log(location); 
}

In that object, you’ll find contentId, contentType, and spaceKey.

3 Likes

thank you. It works! :slight_smile: