Add Additional Namespace & Catalog Request Support#284
Add Additional Namespace & Catalog Request Support#284gdbarron merged 16 commits intoSnow-Shell:masterfrom
Conversation
Fixes error "Id must either be a SysId 32 character alphanumeric or Number with prefix and id." and retains ID from reference table for further lookup.
Additional fixes for reference table lookup where value is not in the 32 character format expected by SNOW.
Co-authored-by: Greg Brownstein <greg@jagtechnical.com>
Add Namespace parameter to support different API endpoints; defaults to 'now'
Versioned PSD with Minor increase for new functionality and backwards-compatible changes.
|
Awesome stuff, I'll review this week! |
Add New-ServiceNowCatalog declaration to FunctionsToExport.
gdbarron
left a comment
There was a problem hiding this comment.
Thanks very much, looks good, just some tweaks here and there :)
|
|
||
| $AddItemCartResponse = Invoke-ServiceNowRestMethod @AddItemToCart | ||
|
|
||
| if ($AddItemCartResponse.cart_id) { |
There was a problem hiding this comment.
why might we not get a value for cart_id that we need this 'if'?
There was a problem hiding this comment.
This is a safety check to make sure the function doesn't continue to checkout if the Invoke results in an error when adding the item to the cart. It may not be necessary but I wanted to be absolutely sure that a checkout wasn't submitted if the Invoke error didn't return a terminating error up the call stack.
Adjusted to include the CheckoutImmediately parameter.
| $SubmitOrderResponse = Invoke-ServiceNowRestMethod @SubmitOrder | ||
| } | ||
| if ( $PassThru ) { | ||
| $SubmitOrderResponse |
There was a problem hiding this comment.
| $SubmitOrderResponse | |
| $SubmitOrderResponse | Select-Object @{'n'='number';'e'={$_.request_number}}, request_id |
consider updating the output to something like the above so it can be piped directly into the other functions, eg. Get-ServiceNowRecord
There was a problem hiding this comment.
Upon further review of the API documentation, I'm not sure how this would behave when a two-step checkout process is configured.
I do not have a way to test two-step checkout at the moment.
There was a problem hiding this comment.
TODO: needs to be tested to validate the return behavior when multiple quantities of a catalog item or multiple catalog items are returned from the submit_order POST.
|
Thanks, I will review these recommendations after November 5th. |
…pporting ID or name lookup for CatalogItem.
…pporting ID or name lookup for CatalogItem.
Adjust New-ServiceNowSession BaseURI output
This PR adds a cmdlet for New-ServiceNowCatalogItem which uses the 'sn_sc' API namespace to add a catalog item request to a cart and then submits the cart as an order.
Extends Get-ServiceNowAuth and Invoke-ServiceNowRestMethod with a namespace parameter to support different Namespace endpoints; backwards compatibility is maintained by defaulting to the 'now' namespace if not specified.