Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
"Releasing Invoice $ReferenceNbr"
$body = @"
`"entity`":{`"id`": `"$EntityID`"}
$HashArguments = @{
Uri = "$AcumaticaEndPoint/entity/default/18.200.001/Invoice/ReleaseInvoice"
Method = 'POST'
Headers = $headers
Body = $body
WebSession = $WebSession
$response = Invoke-RestMethod @HashArguments
$Counter = 0
$MaxLoops = 5 #This will control the number of retries performed.
if ($Counter -eq $MaxLoops)
#We will write a future function to log out and place it here. For now we will just error out.
throw " loop counter has exceeded its threshold when checking it Invoice was released"
#Add a mechanism to stop a potential infinite loop with a counter
$Counter += 1
sleep 1 #Give a little time before the polling check takes place.
$HashArguments = @{
Uri = "$AcumaticaEndPoint/entity/default/18.200.001/Invoice?`$Filter=ReferenceNbr eq `'$ReferenceNbr`'"
Method = 'GET'
Headers = $headers
#Body = $body #Do not send a body param into a GET to prevent errors. PostMan adds this via the snippit
#tool when its not needed
WebSession = $WebSession}
$response = Invoke-RestMethod @HashArguments
$InvoiceAsPSObject = $response | ConvertTo-Json | ConvertFrom-Json
#note in the below we needed to use the $($SomeObject.SomeProperty) to get the value of a propery
#that is on the PSObject into the output string.
"Status Check for Invoice#$ReferenceNbr returned $($InvoiceAsPSObject.Status.value)"
}While ($InvoiceAsPSObject.Status.value -ne 'Open')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.