Connecting Autodesk & ERP
ERP systems that provide an OData interface can be directly connected to applications such as Vault Client, Inventor or AutoCAD.
But also ERP systems which doesn’t expose a web API can be connected using powerGateServer, who then acts as a middleman and translator.

ERP integrations
Vault Clients and CAD applications can be easily connected to ERP systems using the powerGate Cmdlets or the .NET library.
Depending on whether data synchronizations must be fully automated, partially automated or performed manually, an ERP integration can be realized using powerJobs Processor, powerEvents and Autodesk Vault Data Standard.
Scripts
Some PowerShell scripts are delivered with the product, all starting with the name ‘Sample.’.
Their purpose is mainly to help getting started with implementing an ERP integration based on powerEvents.
The following sample scripts are installed to %ProgramData%\coolOrange\powerEvents\Events:
Sample.ConnectToPowerGateServer.ps1 (disabled per default and therefore installed in the .\Disabled subdirectory)
Sample.SyncERPTabConfiguration.ps1 & Sample.DefaultERPTabConfiguration.xml
Sample.TransferERPItemViaFileTab.ps1 & Sample.TransferERPItemViaItemTab.ps1
Sample.TransferERPBOMViaFileTab.ps1 & Sample.TransferERPBOMViaItemTab.ps1
These samples cover the most common scenarios for connecting and exchanging data between Vault and an ERP system.
When starting Vault applications and logging into Vault, the Sample.ConnectToPowerGateServer script automatically connects to the correct powerGateServer (test or productive system). For this the script must first be enabled.
The Sample.SyncERPTabConfiguration provides Tools Menu items for downloading and uploading a configuration for ERP Tabs. When no configuration was previosuly uploaded, a default configuration is uploaded on the first log into Vault.
Afterwards, an “ERP Item” tab and an “ERP BOM” tab are displayed in the Vault Client for selected files and items.
For files, the Sample.TransferERPItemViaFileTab script displays the information of the corresponding ERP Item and the Sample.TransferERPBOMViaFileTab script displays the current bill of materials from the ERP. Both tabs also allow data to be created or changed live in the ERP system.
For items, the Sample.TransferERPItemViaItemTab and Sample.TransferERPBOMViaItemTab scripts display the corresponding information from the ERP system and both also allow creating or changing such data.
For evaluation purposes, the mentioned tabs automatically connect to a Demo ERP system, which means that only demo data is displayed and can be modified.
Therefore, lines such as the following must not be used when implementing ERP integrations and should simply be removed:
Connect-ERP -Service 'http://demo.powergate.online/PGS/ERP/MaterialService' -OnConnect $global:demoERPconnect -ErrorAction Stop
The Tabs are delivered with corresponding .xaml files (Extensible Application Markup Language) which describe their layout, including the controls used (label, text field, combo box, etc.).
Customizations
For all sample scripts and the according xaml files it is recommended to create a copy when they need to be customized.
Disable the used sample script by simply moving it to the %PROGRAMDATA%\coolOrange\powerEvents\Events\Disabled directory.
Modules
The powerGate_Connections.psm1 module is delivered in the Cmdlets installation directory %ProgramFiles%\coolOrange\Modules\powerGate.
It gets automatically imported with the powerGate module and provides global variables and extensions:
The $sapConnect variable for connecting to SAP systems.
The $demoErpConnect variable for connecting to the Demo ERP system.
The $global:Host.PrivateData.OnNonTerminatingError extension ensures that Vault users are notified about connection problems and can better understand whether the problem is caused by their client-machine, by powerGateServer or directly triggered by the ERP system.
Import powerGate module
Before the global variables can be used in -OnConnect of the Connect-ERP, they must be imported using Import-Module powerGate
.
Otherwise it may happen that no successful connection to the ERP system can be established.
Errors
Powershell hosting applications inform scripting guys and Vault users in different ways about Terminating Errors that arise during script or module executions :
powerEvents displays Error Message Boxes
BOM Window displays Error Dialogs during Check- and Transfer operations or failure Icons while loading the BOM tree
powerJobs Processor jobs fail
Autodesk Vault Data Standard writes to the Log File and shows Message Boxes in several customization areas
PowerShell IDE’s display the error message and its stack trace with red text in the terminal when the script execution stops
Instead, when Non-Terminating Errors occur within Cmdlets, the script execution is not stopped by default (see -ErrorAction:Continue
parameter) and further information is available in the global $Error
variable.
For connection problems, these would be the WebRequestException details provided by ERP cmdlets.
By default, Vault users are informed about connection troubles in all types of ERP integrations using the powerGate_Connections.psm1 module.
In applications such as the Vault Client, Inventor or AutoCAD a Connection Error Dialog will be displayed, which helps to understand whether the connection problem was caused by the client-machine (no request was send), the powerGateServer or directly by the ERP system (error response):

All other types of Non-Terminating Errors are displayed using an Error Message Box which helps to identify incorrectly used ERP cmdlets or problematic parameters:

BOM Window - Non-Terminating Errors
Such modal error dialogs are not displayed during the BOM Window Check- and Transfer functions where problems with ERP cmdlets occur.
Instead, the current processed $bom, $bomRow and $item objects are automatically assigned with an Error Status:

The automatically set _StatusDetails
help the Vault user to localize the cause of connection problems more precisely.
Unfortunately the operations are not automatically terminated after problematic ERP cmdlet usages or incorrect parameter values, but also in this case additional stack trace information allows the scripting guy to find the problematic line faster.
Vault Restriction events - Non-Terminating Errors
All Vault Restriction events that encounter ERP cmdlet errors are automatically restricted to prevent the configured process from passing successfully even though connection or cmdlet problems have occurred:

Unfortunately, the executed Restrictions event actions are not automatically aborted directly after problematic ERP cmdlet usages or incorrect parameter values.
Still, additional stack trace information helps the script guy to quickly find and correct the affected ERP cmdlet line.
In any case, all error details are logged and can be found in the logfile.