Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
359 stars 170 forks source link

Updating a Non-Catalog Request #229

Closed gdbarron closed 1 year ago

gdbarron commented 1 year ago

Discussed in https://github.com/Snow-Shell/servicenow-powershell/discussions/228

Originally posted by **DrMarkX** January 10, 2023 Is there a way to update non-catalog requests? I've tried... `Get-ServiceNowRecord -Table 'u_non_catalog_request' -ID NON0292380 | Update-ServiceNowRecord -Values @{work_notes = "Updated by PowerShell"}` But that returns the error message: _Invoke-WebRequest : The remote server returned an error: (400) Bad Request._
gdbarron commented 1 year ago

@DrMarkX, would you mind testing the fix?

DrMarkX commented 1 year ago

We are able to update a non-catalog request. We did have to explicitly reference the table type after the pipe. Get-ServiceNowRecord -Table 'u_non_catalog_request' -ID NON0292380 | Update-ServiceNowRecord -Table 'u_non_catalog_request' -Values @{work_notes = "Updated by PowerShell"}

gdbarron commented 1 year ago

I just did some testing and custom tables don't have a sys_class_name property so Get-ServiceNowRecord isn't passing it on. I'll make the update to account for it.