How to write a User Macro that changes the header titles on the Task Report Macro?

Tristan Albach January 10, 2019

In this discussion 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!

1 answer

1 accepted

1 vote
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

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>
Tristan Albach January 10, 2019

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?

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

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.

Tristan Albach January 10, 2019

Not a worry, this works brilliantly, thanks again!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events