V10 ResourcesGuides
ResourcesGuides
Guides
Back | List of Articles

How to perform the ERP extension deployment?

Last changed in 02/07/2020

This article will show how to perform the ERP extension deployment using the app Inno Setup. This application is free, and it is a software that allows to easily create setups to install programs in Windows.

Before creating a setup to record extensions, it is important to understand how to record extensions and how to automate it:

Perform the deployment

Step 1 - Application download

Start unloading the application available in this location.

Step 2 - Create script to deployment

After installing the application, let's start the script creation process for extension deployment. This creation process can be performed using an assistant made available by the application.

 width=

Step 3 - Configure script sections

In this step, let's start defining the script. There are several sections that can be configured, it is important to see the documents available. In the example, we focus on the vital sections to perform the deployment.

Defines

This section allows to define some constants that will be later used on the script code. In this example, we can define five constants:

;Defines
#define MyAppName "My Extensibility Ext"
#define MyAppPath "{pf}MyExtensibilityExt"
#define MyExtention = "C:UsersDaniel.VieiraDocumentsVisual Studio 2017ProjectsC#V10ExtensibilityERPExtensibilityERPbinDebugExtensibilityERP.dll"
#define MyExtentionFileName = "ExtensibilityERP.dll"
#define MyOutputBaseFilename = "ExtensibilityExt_setup"
MyAppNameName assigned to application being installed
MyAppPathThis constant will later be assigned to the default installation folder
MyExtensionLocation of the extension being deployed
MyExtentionFileNameName of the file that matches the extension
MyOutputBaseFilenameName of the setup being generated

[Setup]

This section contains the global definitions will be used by the installer.

[Setup]
AppName={#MyAppName}
AppVersion=1.0
OutputBaseFilename={#MyOutputBaseFilename}
WizardStyle=modern
DisableWelcomePage=no
DefaultDirName={#MyAppPath}
DisableDirPage = No
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}setup.exe
PrivilegesRequired=admin
AppNameApplication name to install
OutputBaseFilenameName of the setup to be generated
DefaultDirNameDefault installation folder
DisableDirPageIndicates if the installation folder will be shown or not
PrivilegesRequiredIndicates the privileges used in the installation

[Languages]

This section configures the setup language, in this case, it will be Portuguese:

[Languages]
Name: "portuguese"; MessagesFile: "compiler:LanguagesPortuguese.isl"

[Files]

This section specifies the files to perform the deployment, in this example it will only be the extension itself.

[Files]
// Extensions to install
Source: {#MyExtention}; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: RegisterExtraCloseApplicationsResources('{app}{#MyExtentionFileName}')

Note: After installing the extension, a procedure available in the next section will be invoked. This method will be explained later.

[Code]

In the case of a deployment of an ERP extension, installing it locally is not enough. It is also necessary to record it manually in the ERP in the backstage area regarding the extensibility, as explained in the first reference article.

However, it is also worth noting that this record can be performed by the installer, by automating the process as explained in the following steps.

Step 4 - Data collection

To record an ERP extension, it is necessary to collect information, namely, the access credentials to the ERP and the desired company.

In the section [Code] we will place a procedure to configure the installer and show specific user pages, in order to collect this data during the installation process.

This procedure is called InitializeWizard and is only an event that allows to perform changes in the assistant or in the initialization assistant pages.

ERP access credentials

In this page, the access credentials to the ERP and the desired company will be requested to the user.

// Access to the ERP.
UserPage := CreateInputQueryPage(wpWelcome,
'Informação de acesso ao ERP', '',
'Indique as suas credenciais de acesso e a empresa, depois clique em seguinte.');
UserPage.Add('Utilizador:', False);
UserPage.Add('Palavra Chave:', True);
UserPage.Add('Empresa:', False);

Product line

In order to be authenticated in the ERP, it is also necessary to specify a product line, which will be done in a new page.

// Product line.
ProductType := CreateInputOptionPage(UserPage.ID,'Linha de produto', '',
'Indique qual a linha de produto, depois clique em seguinte.',True, False);
ProductType.Add('Executive');
ProductType.Add('Professional');

// Value selected by default.
ProductType.Values[0] := True;

Tipo de extensão

When an extension is recorded in the ERP, it can be available to all companies of to only one. This is where the user must specify it.

// Extension type.
ExtensionTypePage := CreateInputOptionPage(UserPage.ID,
'Tipo de Extensão', '','Indique o tipo de extensão, depois clique em seguinte.',True, False);
ExtensionTypePage.Add('Extensão está disponivel para todas as empresas.');
ExtensionTypePage.Add('Extensão aplica-se apenas a uma empresa.');

// Value selected by default.
ExtensionTypePage.Values[1] := True;

Step 5 - Extension record

As explained previously, after finishing the installation process, the procedure RegisterExtraCloseApplicationsResources will be invoked to record the extension in the ERP.

The second referenced article mentions an automation process when recording extensions, and this mechanism will be identical. It is necessary that in the Apl folder of the ERP, there is the app "RegisterExtension.exe". This app will record the extensions outside the ERP. Its distribution is undertaken by the PLT builds.

When an extension is recorded for all companies, it is stored in the folder "PRIMAVERASG100ConfigL[E][P]CommonExtensions". When it is only available to a company, it will be present on the folder "PRIMAVERASG100ConfigL[E][P]Extensions[Company]".

The first instruction is knowing which one is the ERP Config folder. This information is given by the PERCURSOCONFIG key in the registry.

RegQueryStringValue(HKLM, 'SOFTWAREWOW6432NodePRIMAVERA'+ platRegValue + 'DefaultADM', 'PERCURSOCONFIG', erpFolder)

Next, the existence of the corresponding folder is checked to store the extension, using the information provided by the user.

// What is the extension type?
if (communExtension = '1') then begin

	communExtension := 'True';

	if not(DirExists(erpFolder + 'Extensions' + company)) then 
		CreateDir(erpFolder + 'Extensions' + company);

end else begin      

	communExtension := 'False';

	if not(DirExists(erpFolder + 'CommonExtensions')) then 
		CreateDir(erpFolder + 'CommonExtensions');

end;

To achieve the app that records, it is also necessary to retrieve the Apl folder location, provided by the PERCURSOAPL key of the registry.

RegQueryStringValue(HKLM, 'SOFTWAREWOW6432NodePRIMAVERA'+ platRegValue + 'DefaultADM', 'PERCURSOAPL', percursoAPL)

The next instruction will be the extension record execution. The app receives in the command line, the necessary parameters to record. These parameters are explained in the referenced article.

if FileExists(percursoAPL + 'RegisterExtension.exe') then begin

	// Parameters for the command line.
	cmdLineParams:= company + ' ' + user + ' ' + password + ' ' + platformType + ' "' + strInstallPath + '" ' + communExtension;

	// Extension record in the ERP
	if Exec(ExpandConstant(percursoAPL + 'RegisterExtension.exe'), cmdLineParams, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin

		if ResultCode = 0 then begin
			MsgBox('Registo da extensão concluído com sucesso.', mbInformation, MB_OK);
		end else begin
			MsgBox('Erro ao registar a extensão no ERP, deve efectuar o registto manualmente [' + strInstallPath + '].', mbError, MB_OK);
		end
		
	end

end

This is an example of how to perform the deployment of one or more extensions for the ERP, by recording automatically. The complete script can be transferred here.

Note: In case of installations Server/Station, the deployment only needs to be performed in the server.

Bookmark or share this article
Esta página foi útil?
Obrigado pelo seu voto.

login para deixar a sua opinião.

Obrigado pelo seu feedback. Iremos analisá-lo para continuarmos a melhorar!
Related Articles
Getting Started How to create an integration project with Visual Studio? How to create an Interface Extensibility Project (PEX) with Visual Studio? How to create an API (Engine) extensibility project with Visual Studio? How to create user tabs with Visual Studio?