Restrict macro to specific space
Asked by Amit Anand:

I have created a macro name as "My Task" in Confluence.

\<ac:structured-macro ac:name="tasks-report-macro"\>  
\<ac:parameter ac:name="assignees"\>  
\<ri:user ri:userkey="$action.remoteUser.key"/\>  
\</ac:parameter ac:name="pageSize"\>;10\</ac:parameter\>;  
\</ac:parameter\>  
\</ac:structured-macro\>

Now i need to add parameter so that i can filter current tasks restricted to a specific space ?

Let me know if anyone done this?

Thanks

Amit


Answers:
author: Amit Anand
body: Team,

Any update on this?

If we can create macro where we can **select multiple space at a time ?**

Thanks

Amit Anand


author: Diego
body: Hello [@Amit Anand](/t5/user/viewprofilepage/user-id/705915) !

As I understand, you need to limit your search within the user macro to a specific space based on space key.

You will need to get the value from $spaceManager.getSpace($spaceKey).getName() and then check all space occurrences for the selected Space Key. You can check more information on how to work with velocity loops and classes in these threads and also our documentation. Here, take a look:
> * [++***\[Atlassian Community\] How to link to Space home in User Macro?***++](https://community.atlassian.com/t5/Confluence-questions/How-to-link-to-Space-home-in-User-Macro/qaq-p/632232)
> * [++***\[Atlassian Community\] Retrieving list of users in group macro***++](https://community.atlassian.com/t5/Confluence-questions/Retrieving-list-of-users-in-group-macro/qaq-p/304537)
> * ++***[\[Atlassian Community\] Get Space Name from Space Key](https://community.atlassian.com/t5/Answers-Developer-Questions/Get-Space-Name-from-Space-Key/qaq-p/469914)***++
> * ++***[\[Confluence Server Developer\] Confluence objects accessible from Velocity](https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity/)***++
> * [++***\[Confluence Server Developer\] Velocity template overview***++](https://developer.atlassian.com/server/confluence/velocity-template-overview/)

You can also try to reach out to our sister community, the Developer Community! There you will be able to find skilled help for development questions. Here it is:
> * [++***\[Atlassian Developer Community\] Latest Topics***++](https://community.developer.atlassian.com/c/Confluence)

Let us hear from you!

comments: author: Amit Anand
body: Dear [@Diego](/t5/user/viewprofilepage/user-id/1188952) ,

Thanks for your reply !

I have achieved this with below macro(can able to select single space) **but need to select multiple space at a time so is there a way out to have multiple space selection?**

**Below macro for your reference**

\<ac:structured-macro ac:name="tasks-report-macro"\>

\<ac:parameter ac:name="spaces"\>$paramSpace\</ac:parameter\>

\<ac:parameter ac:name="assignees"\>\<ri:user ri:userkey="$action.remoteUser.key"/\>\</ac:parameter\>

\</ac:structured-macro\>

Thanks

Amit


author: Amit Anand
body: Dear [@Diego](/t5/user/viewprofilepage/user-id/1188952) ,

Let me know if there is a way to create macro where we can **select multiple space at a time ?**

Looking for reply .

Thanks

Amit Anand


Tags: cloud

confluence-app

confluence-cloud