How to write a User Macro that changes the header titles on the Task Report Macro?
Asked by Tristan Albach:

In this [discussion](https://community.atlassian.com/t5/Confluence-questions/Can-we-change-the-headers-for-the-Task-Report-macro/qaq-p/944330?utm_campaign=&utm_content=post&utm_medium=email&utm_source=atlcomm#M129454 "Can we change the headers for the Task Report macro?")I was encouraged to ask the community how to write a User Macro that allows user customization of the header titles for the Task Report Macro. Any help would be greatly appreciated!


Answers:
author: Davin Studer
body: How about something like this? I tried creating a user macro that you could embed a task report in the body, but the task report macro fails to load correctly if you put it inside a user macro. This is the compromise you just need to specify which task report macro on your page you are targeting.

**Macro Name:** change_task_report_headers

**Macro Title:** Change Task Report Headers

**Macro Body Processing:**No macro body

**Template:**

```
## Developed by: Davin Studer## Date created: 01/10/2019## @param Number:title=Task report macro number|type=string|required=true|desc=Which task report macro to apply to.## @param Description:title=Rename Description|type=string|required=false|desc=Rename the "Description" column.## @param DueDate:title=Rename Due date|type=string|required=false|desc=Rename the "Due date" column.## @param Assignee:title=Rename Assignee|type=string|required=false|desc=Rename the "Assignee" column## @param TaskAppears:title=Rename Task appears on|type=string|required=false|desc=Rename the "Task appears on" column.<script type="text/javascript">//<![CDATA[AJS.toInit(function(){    var which = $paramNumber;    which = which - 1; #if ($paramDescription && $paramDescription != "")     AJS.$('[data-macro-name="tasks-report-macro"] th.header-description').eq(which).text('$paramDescription');#end#if ($paramDueDate && $paramDueDate != "")     AJS.$('[data-macro-name="tasks-report-macro"] th.header-duedate').eq(which).text('$paramDueDate');#end#if ($paramAssignee && $paramAssignee != "")     AJS.$('[data-macro-name="tasks-report-macro"] th.header-assignee').eq(which).text('$paramAssignee');#end#if ($paramTaskAppears && $paramTaskAppears != "")     AJS.$('[data-macro-name="tasks-report-macro"] th.header-location').eq(which).text('$paramTaskAppears');#end});//]]></script>
```

comments: author: Tristan Albach
body: Hi Davin,

This is amazing, thank you! I had a question about providing the task report macro to which the customized headers should apply. I tried inputting the number 1 and sure enough it applied the custom headers, but is that the intended approach? If there was more than one Task Report on the page, would they be numbered by the order in which they appear on the page?


author: Davin Studer
body: You are correct. If you put in 1 it will apply to the first. If you put in 2 it will apply to the second. Ideally I could just have the user macro have a body and put the task report macro inside and you would not need to specify which one to target as the user macro would target the task report macros inside it. However, the task report macro doesn't want to render correctly inside of a user macro.


author: Tristan Albach
body: Not a worry, this works brilliantly, thanks again!


Tags: confluence-server

custom-field

report

server

task

user-macro