powergate:code_reference:commandlets:add-erpobject

Add-ERPObject

Cmdlet to create a new entity and transfers it to an ERP-System.

Add-ERPObject [[-EntitySet] <String>] [[-Properties] <Object>]  [<CommonParameters>]

Type Name Description Optional
String EntitySetThe 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 Properties The properties for the entity being createdno

Entity ← on success
empty ← on failure

This commandlet is used to create an entity in the ERP-System.

In the following examples we are using the public OData Services (http://services.odata.org) for demonstration purposes:

Create an orange Juice

Connect-Erp -Service "http://services.odata.org/V4/OData/(S(du4oaehbpzqh2eznhygi1xkg))/OData.svc"
$entity = Add-ERPObject -EntitySet "Products" -Properties @{ 
		"ID "= 5;
		"Name" = "Orange Juice";
		"Description" = "The original Orange Juice. Refreshing!";
		"ReleaseDate" = "2006-08-04T00 =00 =00Z";
		"DiscontinuedDate" = $null;
		"Rating" = 3;
		"Price" = 22.8 
}

Create a person with details (deep create)

Connect-Erp -Service "http://services.odata.org/V4/OData/(S(du4oaehbpzqh2eznhygi1xkg))/OData.svc"
$entity = Add-ERPObject -EntitySet "Products" -Properties @{ 
		"ID" = 3,
		"Name" = "Augustin Hodorsson",
		"PersonDetail" = @{ 
			"PersonID" = 3,
			"Age" = 23,
			"Gender" = $true,
			"Phone" = "(307) 555-4680123"
		}
}

Create a Product entity using New-ErpObject

Connect-Erp -Service "http://services.odata.org/V4/OData/(S(du4oaehbpzqh2eznhygi1xkg))/OData.svc"
$product = New-ERPObject -EntityType 'Product'-Properties @{"ID"=11;"Name"="Forst beer"}
Add-ERPObject -EntitySet "Products" -Properties $product 

<#
ID               : 11
Name             : Forst beer
Description      :
ReleaseDate      : 01.01.0001 00:00:00 +00:00
DiscontinuedDate :
Rating           : 0
Price            : 0
#>