-
Notifications
You must be signed in to change notification settings - Fork 67
Using a template to create New CWMTicketTask
Chris Taylor edited this page Apr 15, 2021
·
8 revisions
We will start by pulling up the New-CWMTemplate and, opening up the API documentation for the endpoint we are working with.
We create a new file New-CWMTicketTask.ps1 in the appropriate directory and, update the function name to match. We then want to update the to match the endpoint we are using.
New enpoints are the most complicated as you need to handle ALL the parameters listed in the schema.
You will want to type all your inputs appropriately
- integer - [int]
- string - [string]
- boolean - [boolean]
- any 'reference' - [hashtable]
- enum - create a validation set
function New-CWMTicketTask {
# 2020.4
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'Used by sub-function')]
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[int]$id,
[int]$ticketId,
[string]$notes,
[boolean]$closedFlag,
[int]$priority,
[hastable]$schedule,
[hashtable]$code,
[string]$resolution,
[ValidateSet('Transfer', 'Delete', 'Done')]
$childScheduleAction,
[int]$childTicketId,
[hashtable]$_info
)
$URI = "https://$($script:CWMServerConnection.Server)/v4_6_release/apis/3.0/service/tickets/$($ticketId)/tasks"
return Invoke-CWMNewMaster -Arguments $PsBoundParameters -URI $URI
}