My Tasks Widget

The My Tasks widget displays a list of the user’s incomplete tasks.

The widget utilizes an HTML file, SQL script and Python script as shown below. Since the tasks list is different for each user, Caching should be set to each user.

HTML Code

Below is the HTML code for the My Tasks widget. As supplied by TouchPoint, the file name is WidgetTasksHTML.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<div class="box">
    <div class="box-title hidden-xs">
        <h5><a href="/TaskSearch">{{WidgetName}}</a></h5>
    </div>
    <a class="visible-xs-block" id="{{WidgetId}}-collapse" data-toggle="collapse" href="#{{WidgetId}}-section" aria-expanded="true" aria-controls="{{WidgetId}}-section">
        <div class="box-title">
            <h5>
                <i class="fa fa-chevron-circle-right"></i>&nbsp;&nbsp;{{WidgetName}}
            </h5>
            {{#ifGT results.Count 0}}
                <div class="pull-right">
                    <span class="badge badge-primary">{{results.Count}}</span>
                </div>
            {{/ifGT}}
        </div>
    </a>
    <div class="collapse in" id="{{WidgetId}}-section">
        {{#ifGT results.Count 0}}
            <ul class="list-group">
                {{#each results}}
                    <li class="list-group-item"><a href="/Task/{{TaskId}}">{{Description}}</a> (<a href="/Person2/{{PeopleId}}">{{Who}}</a>)</li>
                {{/each}}
            </ul>
        {{else}}
            <div class="box-content"></div>
        {{/ifGT}}
    </div>
</div>

SQL Script

Below is the SQL script for the My Tasks widget. As supplied by TouchPoint, the file name is WidgetTasksSQL.

1
2
3
4
5
6
7
8
select t.WhoId, t.Id as TaskId, p.PeopleId, p.[Name] as Who, t.Description from Task t
join People p on p.PeopleId = t.WhoId
where Archive = 0
and (OwnerId = @pid or CoOwnerId = @pid)
and WhoId is not null
and StatusId != (select Id from lookup.TaskStatus where Code = 'C')
and not (OwnerId = @pid and CoOwnerId is not null)
order by CreatedOn

Python Script

Below is the Python script for the My Tasks widget. As supplied by TouchPoint, the file name is WidgetTasksPython.

1
2
3
4
5
6
7
8
def Get():
    sql = Data.SQLContent
    template = Data.HTMLContent
    params = { 'pid': Data.CurrentPerson.PeopleId }
    Data.results = q.QuerySql(sql, params)
    print model.RenderTemplate(template)

Get()


Latest Update 04/30/2020

Added this article.

© 2020 TouchPoint Software, LLC.  All rights reserved.