1C:Enterprise 8.3. Developer Guide. Contents
ADD-INS
1C:Enterprise is an expandable system. Its functionality can be enhanced by add-ins.
The system uses two methods to create add-ins:
using Native API;
using COM technology.
These can be used to develop add-ins for Windows OS and Linux OS as well as for web clients running in Microsoft Internet Explorer version 6.0, 7 and 8 and Mozilla Firefox version 3 (for Windows and Linux OS).
Add-ins designed for web client environment must be packed into a ZIP archive with special structure. This file can also be used at the 1C:Enterprise server and in other clients.
If add-ins have been created using Native API, the following procedure should be followed:
Interface implements a command that installs the add-in on the user's computer (InstallAddIn() global context method). This operation is required in thin and web clients.
The add-in is attached via the AttachAddIn() method. Please remember that attempting to attach a non-installed add-in raises an error.
Attached add-in can be used in compliance with the provided interface.
TIP
It is not recommended to combine codes for add-in installation and attachment. Installation is treated as a one-time event and re-installation causes an interactive exception.
If add-in is packed in to a ZIP archive, its parameters (name of installation file, type, architecture and Web browser to be used) are specified in a special manifest file generated by the add-in developer.
Add-ins obtained from the configuration or infobase are saved and used in subsequent connections without the need to retrieve them again (if an add-in is used at the server, it is only saved for the server working process lifetime).
NOTE
The external CÎÌ components connection using the LoadAddIn(), AttachAddIn() methods and component object registration are performed "for user". If "for user" registration fails, an attempt to perform "for computer" registration will be made.
If an add-in is enabled using the AttachAddIn() method, the parameter in the New() operator (of the created type name) includes the following:
Addin. text
Name specified in the Name parameter of the AttachAddIn() method
Name of the object implemented in the add-in
If a Timer object is implemented in the add-in and the latter is attached using AttachAddIn(URL, "MyName");, creating an object from the add-in requires entering the following ID: New("Addin.MyName.Timer").
32.1. WORK IN THIN AND THICK CLIENTS
When working in thin and thick clients, add-ins developed with both COM and Native API technologies can be used (represented as either separate files stored on disk or special ZIP archives).
Add-ins can be updated by simple re-installation using the InstallAddIn() method.
Add-ins are installed in the %APPDATA%\1C\1cv8\ExtCompT directory. Add-in installation directory is not treated as cache and is not cleared when 1C:Enterprise is invoked using the /ClearCache command line switch. The InstallAddIn() method is required in the thin client.
32.2. WORK IN WEB CLIENT
When working in web clients, add-ins developed with both COM and Native API technologies can be used (packed in special ZIP archives). COM add-ins can be used only if the web client runs under Windows OS. When the add-in is installed, the system asks the user to confirm installation.
For details on Web browser setting for working with add-ins see "1C:Enterprise 8.3. Administrator Guide".
Every add-in is installed as a separate Web browser extension. Extension is an installation package designed for a particular browser type.
Add-ins are installed:
Microsoft Internet Explorer – in %ALLUSERSPROFILE%\Application Data\1C\1CEWebExt (%ALLUSERSPROFILE%\1C\1CEWebExt directory for Windows Vista and later)
Mozilla Firefox – the current browser’s user profile directory (created by the browser)
Google Chrome – in the directory of the current web browser user profile (created by the web browser)
Safari – as defined by the add-in developer Add-ins can be removed:
for Microsoft Internet Explorer browser – via Add/Remove Programs feature of the Control Panel
for Mozilla Firefox Web browser – via extension feature of the Web browser
for Google Chrome web browser – via the mechanism used to work with web browser plug-ins (navigate to chrome://plugins) for Safari web browser – using the standard method
IMPORTANT!
Attachment of add-ins from files stored on disk is not supported in Web browsers for safety reasons.
Note that working with COM objects is available only in Microsoft Internet Explorer and Windows. Also, the COMSafeArray type is not supported as well as an ability to call methods of COM objects that work with this type of value.
To update an add-in do one of the following:
Remove the add-in as described above and re-install it using the InstallAddIn() method.
Change the add-in object name in the add-in source file and manifest file (the add-in file name does not have to change) and re-install the add-in using the InstallAddIn() method.
32.3. WORK ON SERVER
When working on the 1C:Enterprise server, only Native API add-ins are allowed (represented as either separate files stored on disk or special ZIP archives).
Use the AttachAddIn() method to attach an add-in (without the InstallAddIn() method that is unavailable on the server).
When working on the server, it is recommended to attach add-ins shortly before use. Moreover, add-ins used on the server must support all architectures and platforms. This is because server code can be generally executed in various workflows (in different points in time) on various computers. Computers can use both different architectures and different OS.
Add-in file is saved by workflow until restart; therefore, re-attachment of add-in (before workflow restart or switch to another workflow) takes less time than the initial attachment.
32.4. EXAMPLES OF ADD-IN USE
32.4.1. Native API Technology
Native API add-ins can be attached in both client applications and 1C:Enterprise application server.
If an add-in runs on the server, the AttachAddIn() method has to be called every time an add-in instance is created since in the most general case the user cannot predict what server will execute the call (it can be Windows, Linux, 32-bit or 64-bit OS).
32.4.1.1. Add-In Installation on Client
InstallAddIn("CommonTemplate.BarcodeReaderDriver");
32.4.1.2. Load from File on Disk
Add-in file must be located on the user's computer and be available in the OS search path (PATH environment variable).
SysInfo = New SystemInformation; If SysInfo.PlatformType = PlatformType.Windows_x86 Then AttachAddIn("AddInCPP.dll", "MyName", AddInType.Native); ElseIf SysInfo.PlatformType = PlatformType.Windows_x86_64 Then AttachAddIn("AddInCPP64.dll", "MyName", AddInType.Native); ElseIf SysInfo.PlatformType = PlatformType.Linux_x86 Then AttachAddIn("libAddInCPP.so", "MyName", AddInType.Native); Else AttachAddIn("libAddInCPP64.so", "MyName", AddInType.Native); EndIf; AddInObject = New("AddIn.MyName.ComponentExtension");
NOTE
Please note how parameter in the New command is generated.
32.4.1.3. Load Add-In from Template
SysInfo = New SystemInformation; If SysInfo.PlatformType = PlatformType.Windows_x86 Then AttachAddIn("DataProcessor.AddIn.Template.AddInWindows32", "MyName", AddInType.Native); ElseIf SysInfo.PlatformType = PlatformType.Windows_x86_64 Then AttachAddIn("DataProcessor. AddIn.Template.AddInWindows64", "MyName", AddInType.Native); ElseIf SysInfo.PlatformType = PlatformType.Linux_x86 Then AttachAddIn("DataProcessor.AddIn.Template.AddInLinux32", "MyName", AddInType.Native); Else AttachAddIn("DataProcessor. AddIn.Template.AddInLinux64", "MyName", AddInType.Native); EndIf; AddInObject = New("AddIn.MyName.ComponentExtension");
NOTE
Please note how parameter in the New command is generated.
32.4.1.4. Load from Infobase
Infobase must contain the AddIns catalog and attributes for specified names of the ValueStorage type with add-in files.
Var Ref; SysInfo = New SystemInformation; If SysInfo.PlatformType = PlatformType.Windows_x86 Then Ref = GetURL(Catalogs.AddIns.FindByCode("000000001"), "AddInWindows32"); ElseIf SysInfo.PlatformType = PlatformType.Windows_x86_64 Then Ref = GetURL(Catalogs.AddIns.FindByCode("000000001"), "AddInWindows64"); ElseIf SysInfo.PlatformType = PlatformType.Linux_x86 Then Ref = GetURL(Catalogs.AddIns.FindByCode("000000001"), "AddInLinux32"); Else Ref = GetURL(Catalogs.AddIns.FindByCode("000000001"), "AddInLinux64"); EndIf; AttachAddIn(Ref,"MyName", AddInType.Native); AddInObject = New("AddIn.MyName.ComponentExtension");
NOTE
Please note how parameter in the New command is generated.
Using examples for Native API add-ins the user can also attach COM add-ins for Windows OS only.
32.4.1.5. Attach Add-In from ZIP Archive
The configuration must contain a BarcodeReaderDriver common template of the BinaryData type. This template stores a special ZIP archive with add-ins for all the supported OS, browsers and CPU architecture.
AttachAddIn("CommonTemplate.BarcodeReaderDriver", "Reader"); AddIn = New("AddIn.Reader.BarcodeReader");
NOTE
Please note how parameter in the New command is generated.
32.4.2. COM Technology
32.4.2.1. Load Add-In
LoadAddIn("MyComponent.dll"); AddIn = New("AddIn.ComponentExtension");
32.4.2.2. Attach Add-In
AttachAddIn("AddIn.MyObject"); AddIn = New("AddIn.ComponentExtension");
NOTE
LoadAddIn() command is used for compatibility with previous 1C:Enterprise versions.