Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix New-ServiceNowChangeTask not linking to parent #256

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ServiceNow/Public/New-ServiceNowChangeRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
.PARAMETER ConfigurationItem
Full name or sys_id of the configuration item to be associated with the change

.PARAMETER InputData
.PARAMETER CustomField
Field values which aren't one of the built in function properties

.PARAMETER ServiceNowSession
Expand Down Expand Up @@ -109,8 +109,8 @@ function New-ServiceNowChangeRequest {
[string] $ConfigurationItem,

[parameter()]
[Alias('CustomFields')]
[hashtable] $InputData,
[Alias('CustomFields', 'InputData')]
[hashtable] $CustomField,

[Parameter()]
[Hashtable] $Connection,
Expand Down Expand Up @@ -141,12 +141,12 @@ function New-ServiceNowChangeRequest {
}

# add custom fields
$duplicateValues = ForEach ($Key in $InputData.Keys) {
$duplicateValues = ForEach ($Key in $CustomField.Keys) {
If ( $values.ContainsKey($Key) ) {
$Key
}
Else {
$values.Add($Key, $InputData[$Key])
$values.Add($Key, $CustomField[$Key])
}
}

Expand Down
11 changes: 6 additions & 5 deletions ServiceNow/Public/New-ServiceNowChangeTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function New-ServiceNowChangeTask {
Return the newly created item details

.EXAMPLE
New-ServiceNowChangeTask -ChangeRequest RITM0010001 -ShortDescription 'New PS change request' -Description 'This change request was created from Powershell' -AssignmentGroup ServiceDesk
New-ServiceNowChangeTask -ChangeRequest CHG0010001 -ShortDescription 'New PS change request' -Description 'This change request was created from Powershell' -AssignmentGroup ServiceDesk

Create a new task

Expand Down Expand Up @@ -82,6 +82,7 @@ function New-ServiceNowChangeTask {
switch ($PSBoundParameters.Keys) {
'ChangeRequest' {
$createValues.parent = $ChangeRequest
$createValues.change_request = $ChangeRequest
}

'ShortDescription' {
Expand All @@ -101,11 +102,11 @@ function New-ServiceNowChangeTask {
}
}

$CustomField.GetEnumerator() | ForEach-Object {
if ( $createValues.($_.Key) ) {
Write-Warning ('Custom field {0} has already been added via parameter' -f $_.Key)
foreach ($key in $CustomField.Keys) {
if ( $createValues.$key ) {
Write-Warning "Custom field '$key' has already been provided via one of the dedicated parameters"
} else {
$createValues.Add($_.Key, $_.Value)
$createValues.Add($key, $CustomField.$key)
}
}

Expand Down
12 changes: 6 additions & 6 deletions ServiceNow/Public/New-ServiceNowIncident.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Generates a new ServiceNow Incident using predefined or other field values
.PARAMETER ConfigurationItem
Full name or sys_id of the configuration item to be associated with the change

.PARAMETER InputData
.PARAMETER CustomField
Field values which aren't one of the built in function properties

.PARAMETER ServiceNowSession
Expand All @@ -56,7 +56,7 @@ Generate a basic Incident attributed to the caller "UserName" with descriptions,
Category = "Office"
Subcategory = "Outlook"
ConfigurationItem = "UserPC1"
InputData = @{u_custom1 = "Custom Field Entry"
CustomField = @{u_custom1 = "Custom Field Entry"
u_another_custom = "Related Test"}
}
New-ServiceNowIncident @IncidentParams
Expand Down Expand Up @@ -93,8 +93,8 @@ function New-ServiceNowIncident {
[string] $ConfigurationItem,

[parameter()]
[Alias('CustomFields')]
[hashtable] $InputData,
[Alias('CustomFields', 'InputData')]
[hashtable] $CustomField,

[Parameter()]
[Hashtable] $Connection,
Expand Down Expand Up @@ -124,12 +124,12 @@ function New-ServiceNowIncident {
}

# add custom fields
$duplicateValues = ForEach ($Key in $InputData.Keys) {
$duplicateValues = ForEach ($Key in $CustomField.Keys) {
If ( $values.ContainsKey($Key) ) {
$Key
}
Else {
$values.Add($Key, $InputData[$Key])
$values.Add($Key, $CustomField[$Key])
}
}

Expand Down
Loading