The objective is to import a data load from Excel into a pre-registered data table using an API (Application Programming Interface) → URL.../api/DataLoad/LoadExcelIntoDataTable
, where we will insert parameters with the code of the source data table, the column code, and the row code where the file is located in the source data table, and the code of the destination data table. The processed data will go to the destination dataTable where we pass the codes through these parameters to the API via the QueryString. The process retrieves the necessary information to populate the data table in the Excel file, based on the column name in the data table and the column headers in the Excel file, which must match. It also takes into account the data type of the destination data table, attempting type conversions when necessary.
The prerequisites for the functionality are simply a user logged into T6, a data form with a file type column for uploading the Excel file, and a destination data table.
We need to configure some user permissions as system prerequisites to create the process and workflow trigger to upload data from Excel to T6.
The process is based on the columns of the destination data table. All columns from the destination table that have a counterpart with the same name in the Excel file (header) are imported. That is, columns present in the Excel file that do not exist in the data table are ignored. The data table’s type configuration and constraints are also considered. If the data table cannot have a particular field as null and the file does not provide this information, the import will not be possible. In this case, the information must be included in the Excel file or the data table should be modified to allow null values.
The process looks in the table referenced by dataTableSourceCode, in the Excel file located in the column and row specified by the sourceRowCode and sourceColumnCode parameters, respectively, and imports the file into the data table specified in the dataTableDestinationCode parameter.
This API accepts 4 parameters via querystring:
REP_DATATABLE_COLUMNS
table in the database server under the codDataColumn
column, and determine which row contains the Excel file added to the source data table. (This information, along with the sourceRowCode parameter, specifies which column in the source table the file is located).An example of how the QueryString will look for use: URL.../api/DataLoad/LoadExcelIntoDataTable?dataTableSourceCode=***&sourceColumnCode=***&sourceRowCode=***&dataTableDestinationCode=***
The process will only import the file in its entirety; if any errors occur, the entire process will be canceled, reverted, and a notification will be displayed in the notifications menu.
To use the import of Excel data into T6 data tables, we first need an Excel file to attach to the source table.
Within T6, we will need to create a source data table (Source), a destination data table, and a data form for each table.
When creating columns in the destination data table, it is mandatory that the column names exactly match the headers in the Excel file, and the column type must be compatible with the data type in the Excel file. If the type is not compatible, T6 will attempt to perform the conversion.
If the process fails, it will be necessary to adjust the data table or the Excel file, possibly requiring renaming columns in the table or the Excel file headers. Failures can also occur due to data table constraints, such as disallowed null fields or incompatible data types.
URL.../api/DataLoad/LoadExcelIntoDataTable?dataTableSourceCode=***&sourceColumnCode=***&sourceRowCode=***&dataTableDestinationCode=***
(we can manipulate the API parameter values using the Instance(workflowParameter) function).
If an error occurs during the API insertion, a system notification will be generated informing you of the issue.
For information on configuring and implementing Swagger, visit our help center: Swagger.
To open Swagger, use the endpoint: URL.../swagger/index.html
qablue.tech6cloud.com/swagger/index.html
; (In this case, qablue is your domain name.)(IIS server)/(application name in IIS)/swagger/index.html
The URL provided before the API will depend on your domain in the cloud, or, in the case of an on-premises environment, on the settings provided in your Internet Information Services (IIS).
When accessing the endpoint, a page will open containing all the system's APIs. Locate the API (/api/DataLoad/LoadExcelIntoDataTable
) and click on to expand it:
When expanding the API, the possible responses that the system can return will also be displayed, as well as a detailed view of the request, such as: