Remove-ERPObject
Cmdlet to remove a specific entity from the ERP-System.
Syntax
Remove-ERPObject [[-EntitySet] <String>] [[-Keys] <Object>] [<CommonParameters>]
Parameters
Type |
Name |
Description |
Optional |
---|---|---|---|
String |
EntitySet |
The EntitySet name where the item is located. It is also possible to specify additional namespaces or the whole url (e.g MaterialService/Materials, http://localhost:8080/PGS/ERP/MaterialService/Materials) |
no |
Hashtable / PSObject |
Keys |
The reference properties for the searching item |
Return type
Bool:
$true ← on success.
$false ← on failure. Exception/ErrorMessage can be accessed using $Error.
If the cmdlet fails due to error responses returned by the ERP system, the $Error variable provides a WebRequestException .
Remarks
This Cmdlet is used to delete a specific object from the ERP System.
Examples
In the following examples we are using public OData Services (http://services.odata.org) for demonstration purposes:
Remove Product with Id 1
1 2 | Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/" Remove-ErpObject -EntitySet "Products" -Keys @{"ID"=1} |
Search for Product and remove it
1 2 3 | Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/" $product = Get-ERPObject -EntitySet "Products" -Keys @{"ID"=10} Remove-ErpObject -EntitySet "Products" -Keys $product._Keys |
Error handling, analyze why the ERP object could not be removed, by using $Error
1 2 3 4 5 6 | Connect-ERP -Service "http://services.odata.org/V3/(S(xnnohcch2jddbn1z1ytpfni2))/OData/OData.svc/" $result = Remove-ErpObject -EntitySet "Products" -Keys @{} if(-not $result){ $Error[0].Exception #"Following mandatory properties in entity 'Product' are missing: 'ID'" } |