Sample.ConnectToPowerGateServer

This sample script is required for the realization of ERP intergrations in which powerGateServer plugins are provided.
It shows how to automatically connect to powerGateServer when Vault users log into Vault from within the Vault Client or Inventor.

The location of the powerGateServer is determined based on the name of the Vault that is connected to:

  • When connecting to a Vault named “TestVault” the services setup up on the local powerGateServer environment are connected (they may still be under development).

  • When connecting to Vaults with other names it is assumed that the powerGateServer is running on the same machine as the Vault Server

Requirements

Regardless of the names of the installed services on the powerGateServer, the event script connects to its CatalogService.
This way, the required custom plugins can be easily installed and it is ensured that only these services are connected.

powerGateServer installations include an ERP Plugin by default, which is for example not required to implement ERP integrations and it gets therefore completely ignored.
It is therefore even recommended to install the powerGateServer without ‘ERP Plugin’ on test and productive environments.

On test environments it is necessary to ensure that these plugins are actually connected to the test-ERP system!
Then, by creating a Vault called “TestVault”, it is possible to ensure that the application is connected to the test ERP, by simply logging out and back into this new Vault.

Customization

When customizing the script, it is recommended to create a copy of the script, customize it accordingly and then enabling it.

The script registers to the LoginVault_Post event and tries to connect to a powerGateServer using Connect-ERP.
Which Vault name maps to which powerGateServer service URLs can be customized by adapting the following section:

Register-VaultEvent -EventName LoginVault_Post -Action {
	Disconnect-ERP

	# To configure for example to connect to individual services for a Vault named ‘Testing’
	if($vaultConnection.Vault -eq 'Testing') {
		$connected = Connect-ERP -Service 'https://sap_test_environment/sap/opu/odata/arcona6/MATERIAL_SRV' -OnConnect $global:sapConnect
		$connected = Connect-ERP -Service 'https://sap_test_environment/sap/opu/odata/arcona6/BILL_OF_MATERIAL_SRV' -OnConnect $global:sapConnect
	}elseif(...){

Enabling the script

In the default delivery the event registration for this script is disabled and located in the %PROGRAMDATA%\coolOrange\powerEvents\Events\Disabled folder.
It can be enabled for the Vault Client and Inventor by moving the script to the %PROGRAMDATA%\coolOrange\powerEvents\Events folder.

To avoid error situations caused by entityset-conflicts with the public Demo ERP system, it is recommended to disable all sample Tabs as well afterwards.
For this also move all %PROGRAMDATA%\coolOrange\powerEvents\Events\Sample.Transfer…Tab.ps1 files to the %PROGRAMDATA%\coolOrange\powerEvents\Events\Disabled folder.