Skip to content

Commit 64a1958

Browse files
Merge pull request #54 from squaredup/AutoTask-statusmap
AutoTask: Dynamic status/priority lookups, Company variable, and OOB dashboard improvements (v1.0.4)
2 parents 7ae174c + a62676b commit 64a1958

10 files changed

Lines changed: 229 additions & 200 deletions

File tree

plugins/AutoTask/v1/custom_types.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,19 @@
3333
"icon": "file-text",
3434
"singular": "Contract",
3535
"plural": "Contracts"
36+
},
37+
{
38+
"name": "AutotaskTicketStatus",
39+
"sourceType": "autotask-ticket-status",
40+
"icon": "circle-dot",
41+
"singular": "Ticket Status",
42+
"plural": "Ticket Statuses"
43+
},
44+
{
45+
"name": "AutotaskTicketPriority",
46+
"sourceType": "autotask-ticket-priority",
47+
"icon": "arrow-up-circle",
48+
"singular": "Ticket Priority",
49+
"plural": "Ticket Priorities"
3650
}
3751
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const priorityField = data.fields.find(f => f.name === "priority");
2+
const values = priorityField ? priorityField.picklistValues : [];
3+
result = values
4+
.filter(pv => pv.isActive)
5+
.sort((a, b) => a.sortOrder - b.sortOrder)
6+
.map(pv => ({ id: String(pv.value), name: pv.label }));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const statusField = data.fields.find(f => f.name === "status");
2+
const values = statusField ? statusField.picklistValues : [];
3+
result = values
4+
.filter(pv => pv.isActive)
5+
.sort((a, b) => a.sortOrder - b.sortOrder)
6+
.map(pv => ({ id: String(pv.value), name: pv.label }));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "ticketPriorities",
3+
"displayName": "Ticket Priorities",
4+
"description": "All ticket priorities from AutoTask",
5+
"tags": ["Tickets"],
6+
"baseDataSourceName": "httpRequestUnscoped",
7+
"visibility": { "type": "hidden" },
8+
"timeframes": false,
9+
"config": {
10+
"httpMethod": "get",
11+
"endpointPath": "atservicesrest/v1.0/Tickets/entityInformation/fields",
12+
"postRequestScript": "ticketPriorities.js",
13+
"paging": { "mode": "none" }
14+
},
15+
"metadata": [
16+
{ "name": "id", "displayName": "Priority ID", "shape": "string", "role": "value", "visible": false },
17+
{ "name": "name", "displayName": "Priority Name", "shape": "string", "role": "label" }
18+
]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "ticketStatuses",
3+
"displayName": "Ticket Statuses",
4+
"description": "All active ticket statuses from AutoTask, including custom statuses",
5+
"tags": ["Tickets"],
6+
"baseDataSourceName": "httpRequestUnscoped",
7+
"visibility": { "type": "hidden" },
8+
"timeframes": false,
9+
"config": {
10+
"httpMethod": "get",
11+
"endpointPath": "atservicesrest/v1.0/Tickets/entityInformation/fields",
12+
"postRequestScript": "ticketStatuses.js",
13+
"paging": { "mode": "none" }
14+
},
15+
"metadata": [
16+
{ "name": "id", "displayName": "Status ID", "shape": "string", "role": "value", "visible": false },
17+
{ "name": "name", "displayName": "Status Name", "shape": "string", "role": "label" }
18+
]
19+
}

plugins/AutoTask/v1/dataStreams/tickets.json

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"config": {
1212
"httpMethod": "get",
1313
"expandInnerObjects": true,
14-
"endpointPath": "atservicesrest/v1.0/Tickets/query?search={\"MaxRecords\":500,\"filter\":[{\"op\":\"in\",\"field\":\"status\",\"value\":[{{statusFilter}}]},{\"op\":\"in\",\"field\":\"priority\",\"value\":[{{priorityFilter}}]},{\"op\":\"gte\",\"field\":\"lastActivityDate\",\"value\":\"{{timeframe.start}}\"},{\"op\":\"lte\",\"field\":\"lastActivityDate\",\"value\":\"{{timeframe.end}}\"}]}",
14+
"endpointPath": "atservicesrest/v1.0/Tickets/query?search={\"MaxRecords\":500,\"filter\":[{{statusFilter ? '{\"op\":\"in\",\"field\":\"status\",\"value\":[' + statusFilter + ']},' : ''}}{{priorityFilter ? '{\"op\":\"in\",\"field\":\"priority\",\"value\":[' + priorityFilter + ']},' : ''}}{\"op\":\"gte\",\"field\":\"lastActivityDate\",\"value\":\"{{timeframe.start}}\"},{\"op\":\"lte\",\"field\":\"lastActivityDate\",\"value\":\"{{timeframe.end}}\"}]}",
1515
"postRequestScript": "tickets.js",
1616
"pathToData": "items",
1717
"paging": {
@@ -28,28 +28,33 @@
2828
{ "name": "id", "displayName": "Ticket ID", "shape": "string", "visible": false },
2929
{ "name": "title", "displayName": "Title" },
3030
{ "name": "description", "displayName": "Description", "visible": false },
31+
{ "name": "status", "displayName": "Status (Raw)", "sourceType": "autotask-ticket-status", "shape": "string", "visible": false },
3132
{
3233
"name": "statusName",
3334
"displayName": "Status",
34-
"visible": true,
35+
"sourceId": "status",
36+
"objectPropertyPath": "name"
37+
},
38+
{
39+
"name": "statusHealth",
40+
"displayName": "Status Health",
3541
"computed": true,
36-
"valueExpression": "{{ $['status'] == 1 ? 'New' : $['status'] == 5 ? 'Complete' : $['status'] == 8 ? 'In Progress' : $['status'] == 9 ? 'Waiting Customer' : $['status'] == 10 ? 'Waiting Materials' : $['status'] == 11 ? 'Waiting Vendor' : $['status'] == 12 ? 'Escalate' : $['status'] == 13 ? 'Waiting Approval' : 'Unknown' }}",
42+
"valueExpression": "{{ $['statusName'] }}",
3743
"shape": ["state", {
3844
"map": {
3945
"success": ["Complete"],
4046
"error": ["Escalate"],
41-
"warning": ["New", "In Progress"],
42-
"unknown": ["Waiting Customer", "Waiting Materials", "Waiting Vendor", "Waiting Approval", "Unknown"]
47+
"warning": ["New", "In Progress", "Waiting Customer", "Waiting Materials", "Waiting Vendor", "Waiting for Vendor", "Waiting Approval"]
4348
}
4449
}]
4550
},
4651
{
4752
"name": "priorityName",
4853
"displayName": "Priority",
49-
"computed": true,
50-
"valueExpression": "{{ $['priority'] == 1 ? 'Critical' : $['priority'] == 2 ? 'High' : $['priority'] == 3 ? 'Medium' : $['priority'] == 4 ? 'Low' : 'Unknown' }}"
54+
"sourceId": "priority",
55+
"objectPropertyPath": "name"
5156
},
52-
{ "name": "priority", "displayName": "Priority (Raw)", "shape": ["number", { "decimalPlaces": 0 }], "visible": false },
57+
{ "name": "priority", "displayName": "Priority (Raw)", "sourceType": "autotask-ticket-priority", "shape": "string", "visible": false },
5358
{ "name": "companyID", "sourceType": "autotask-company", "shape": "string", "visible": false },
5459
{ "name": "companyName", "displayName": "Company", "sourceId": "companyID", "objectPropertyPath": "name" },
5560
{ "name": "contactID", "sourceType": "autotask-contact", "shape": "string", "visible": false },
@@ -137,41 +142,23 @@
137142
"label": "Status",
138143
"allowCustomValues": true,
139144
"isMulti": true,
140-
"defaultValue": "1,5,8,9,10,11,12,13",
141145
"data": {
142-
"source": "fixed",
143-
"values": [
144-
{ "value": "1,5,8,9,10,11,12,13", "label": "All Statuses" },
145-
{ "value": "1", "label": "New" },
146-
{ "value": "8", "label": "In Progress" },
147-
{ "value": "9", "label": "Waiting Customer" },
148-
{ "value": "10", "label": "Waiting Materials" },
149-
{ "value": "11", "label": "Waiting Vendor" },
150-
{ "value": "13", "label": "Waiting Approval" },
151-
{ "value": "12", "label": "Escalate" },
152-
{ "value": "5", "label": "Complete" }
153-
]
154-
},
155-
"validation": { "required": true }
146+
"source": "dataStream",
147+
"dataStreamName": "ticketStatuses",
148+
"dataSourceConfig": {}
149+
}
156150
},
157151
{
158152
"name": "priorityFilter",
159153
"type": "autocomplete",
160154
"label": "Priority",
161155
"allowCustomValues": true,
162156
"isMulti": true,
163-
"defaultValue": "1,2,3,4",
164157
"data": {
165-
"source": "fixed",
166-
"values": [
167-
{ "value": "1,2,3,4", "label": "All Priorities" },
168-
{ "value": "1", "label": "Critical" },
169-
{ "value": "2", "label": "High" },
170-
{ "value": "3", "label": "Medium" },
171-
{ "value": "4", "label": "Low" }
172-
]
173-
},
174-
"validation": { "required": true }
158+
"source": "dataStream",
159+
"dataStreamName": "ticketPriorities",
160+
"dataSourceConfig": {}
161+
}
175162
}
176163
]
177164
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"name": "Companies",
4+
"matches": {
5+
"sourceType": {
6+
"type": "oneOf",
7+
"values": ["autotask-company"]
8+
}
9+
},
10+
"variable": {
11+
"name": "Company",
12+
"allowMultipleSelection": true,
13+
"default": "none",
14+
"type": "object"
15+
}
16+
}
17+
]

0 commit comments

Comments
 (0)