Skip to content

Commit 8f0f322

Browse files
committed
Added ability to add a label on the planner task
1 parent 4c98d74 commit 8f0f322

File tree

6 files changed

+78
-6
lines changed

6 files changed

+78
-6
lines changed

documentation/Add-PnPPlannerTask.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ Adds a new task to a planner bucket
2222
### By Group
2323
```powershell
2424
Add-PnPPlannerTask -Group <PlannerGroupPipeBind> -Plan <PlannerPlanPipeBind> -Bucket <PlannerBucketPipeBind> -Title <String>
25-
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>]
25+
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>] [-AppliedCategories <AppliedCategories>]
2626
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>] [-OutputTask]
2727
2828
```
2929

3030
### By Plan Id
3131
```powershell
3232
Add-PnPPlannerTask -Bucket <PlannerBucketPipeBind> -PlanId <String> -Title <String>
33-
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>]
33+
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>] [-AppliedCategories <AppliedCategories>]
3434
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>] [-OutputTask]
3535
3636
```
@@ -42,21 +42,21 @@ This cmdlet adds a new task to Planner bucket
4242

4343
### Example 1
4444
```powershell
45-
Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -Title "Design booth layout"
45+
Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -Title "Design booth layout" -AppliedCategories @{"Category1"=$true,"Category3"=$true}
4646
```
4747

4848
This cmdlet adds a new task.
4949

5050
### Example 2
5151
```powershell
52-
Add-PnPPlannerTask -PlanId "QvfkTd1mc02gwxHjHC_43JYABhAy" -Bucket "Todos" -Title "Design booth layout"
52+
Add-PnPPlannerTask -PlanId "QvfkTd1mc02gwxHjHC_43JYABhAy" -Bucket "Todos" -Title "Design booth layout" -AppliedCategories @{"Category1"=$true,"Category3"=$true}
5353
```
5454

5555
This cmdlet adds a new task.
5656

5757
### Example 3
5858
```powershell
59-
Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -Title "Design booth layout" -AssignedTo "user@contoso.com","manager@contoso.com"
59+
Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -Title "Design booth layout" -AssignedTo "user@contoso.com","manager@contoso.com" -AppliedCategories @{"Category1"=$true,"Category3"=$true}
6060
```
6161

6262
This cmdlet adds a new task and assigns to user@contoso.com and manager@contoso.com
@@ -145,6 +145,21 @@ Accept pipeline input: False
145145
Accept wildcard characters: False
146146
```
147147
148+
### -AppliedCategories
149+
The applied categories represent the labels as shown in the UI of the planner task. Categories are 'hardcoded' as such in Planner, e.g. you can set Category1 to Category25, each having its own color. Labels, if customized in planner will be set accordingly to the ones defined. You can either copy the value from an existing task (e.g. $task = Get-PnPPlannerTask, Add-PnPPlannerTask -PlanId <yourid> -AppliedCategories $task.AppliedCategory) or you can define it as a new object: @{"Category1"=$true,"Category5"=$true}
150+
151+
```yaml
152+
Type: AppliedCategories
153+
Parameter Sets: (All)
154+
Aliases:
155+
156+
Required: False
157+
Position: Named
158+
Default value: None
159+
Accept pipeline input: False
160+
Accept wildcard characters: False
161+
```
162+
148163
### -AssignedTo
149164
Specify the email(s) of the user to assign the task to.
150165
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
4+
using PnP.PowerShell.Commands.Model.Graph;
5+
6+
namespace PnP.PowerShell.Commands.Model.Planner
7+
{
8+
public class PlannerPlanDetails
9+
{
10+
[JsonPropertyName("@odata.etag")]
11+
public string ETag { get; set; }
12+
13+
public Dictionary<string,string> CategoryDescriptions { get; set; }
14+
}
15+
}

src/Commands/Model/Planner/PlannerTask.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class TaskAssignment
4949
{
5050
[JsonPropertyName("@odata.type")]
5151
public string Type { get; set; } = "#microsoft.graph.plannerAssignment";
52-
52+
5353
public DateTime? AssignedDateTime { get; set; }
5454
public string OrderHint { get; set; } = " !";
5555
public IdentitySet AssignedBy { get; set; }
@@ -63,6 +63,25 @@ public class AppliedCategories
6363
public bool? Category4 { get; set; }
6464
public bool? Category5 { get; set; }
6565
public bool? Category6 { get; set; }
66+
public bool? Category7 { get; set; }
67+
public bool? Category8 { get; set; }
68+
public bool? Category9 { get; set; }
69+
public bool? Category10 { get; set; }
70+
public bool? Category11 { get; set; }
71+
public bool? Category12 { get; set; }
72+
public bool? Category13 { get; set; }
73+
public bool? Category14 { get; set; }
74+
public bool? Category15 { get; set; }
75+
public bool? Category16 { get; set; }
76+
public bool? Category17 { get; set; }
77+
public bool? Category18 { get; set; }
78+
public bool? Category19 { get; set; }
79+
public bool? Category20 { get; set; }
80+
public bool? Category21 { get; set; }
81+
public bool? Category22 { get; set; }
82+
public bool? Category23 { get; set; }
83+
public bool? Category24 { get; set; }
84+
public bool? Category25 { get; set; }
6685

6786
[JsonExtensionData]
6887
public IDictionary<string, object> AdditionalData { get; set; }

src/Commands/Planner/AddPlannerTask.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class AddPlannerTask : PnPGraphCmdlet
5656
[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
5757
public SwitchParameter OutputTask;
5858

59+
[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
60+
public AppliedCategories AppliedCategories;
61+
5962
protected override void ExecuteCmdlet()
6063
{
6164
PlannerTask createdTask;
@@ -116,6 +119,11 @@ protected override void ExecuteCmdlet()
116119
}
117120
}
118121

122+
if(ParameterSpecified(nameof(AppliedCategories)))
123+
{
124+
newTask.AppliedCategories = AppliedCategories;
125+
}
126+
119127
// By Group
120128
if (ParameterSetName == ParameterName_BYGROUP)
121129
{

src/Commands/Planner/SetPlannerTask.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public class SetPlannerTask : PnPGraphCmdlet
4444
[Parameter(Mandatory = false)]
4545
public string[] AssignedTo;
4646

47+
[Parameter(Mandatory = false)]
48+
public AppliedCategories AppliedCategories;
49+
4750
protected override void ExecuteCmdlet()
4851
{
4952
var existingTask = PlannerUtility.GetTask(GraphRequestHelper, TaskId, false, false);
@@ -87,6 +90,11 @@ protected override void ExecuteCmdlet()
8790
plannerTask.StartDateTime = StartDateTime.ToUniversalTime();
8891
}
8992

93+
if(ParameterSpecified(nameof(AppliedCategories)))
94+
{
95+
plannerTask.AppliedCategories = AppliedCategories;
96+
}
97+
9098
if (ParameterSpecified(nameof(AssignedTo)))
9199
{
92100
var errors = new List<Exception>();

src/Commands/Utilities/PlannerUtility.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public static PlannerPlan GetPlan(ApiRequestHelper requestHelper, string planId,
4646
return plan;
4747
}
4848

49+
public static PlannerPlanDetails GetPlanDetails(ApiRequestHelper requestHelper, string planId)
50+
{
51+
var plan = requestHelper.Get<PlannerPlanDetails>($"v1.0/planner/plans/{planId}/details");
52+
53+
return plan;
54+
}
55+
4956
public static PlannerPlan CreatePlan(ApiRequestHelper requestHelper, string groupId, string title)
5057
{
5158
var stringContent = new StringContent(JsonSerializer.Serialize(new { owner = groupId, title = title }));

0 commit comments

Comments
 (0)