Sample.ConnectToPowerGateServer

To evaluate our sample ERP features in Vault Client and Inventor, this client customization automatically connects to the public Demo ERP system by default.

The sample script is also 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, this client customization 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.

Modifications

To modify this script to your needs, it is recommended to create a copy of the sample script, customize it accordingly and then disable this sample script.

In order that no connection to the Demo ERP system is established, the following variable must first be changed to $false:

16
$connectToDemoErpSystem = $false

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 adjusted by adapting the following section:

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

   $connectToDemoErpSystem = $false
   ...
   
   # 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(...){

Disabling the script

After the installation on new environments this script is enabled by default for the Vault Client and Inventor.
To globally disable this client customization, move the script file to the %PROGRAMDATA%\coolOrange\Client Customizations\Disabled directory.

Note

Please note that after updates from v23.0.10 and older, this script is automatically disabled and installed in the %PROGRAMDATA%\coolOrange\Client Customizations\Disabled directory.
Scripting guys can then enable and review this customization in a test environment before deploying the script in production ERP integrations.