| Docs Help
  AppSource  
Docs  /  NVXCFT Cloud File Transfer  /  Tasks

Working with the Cloud File Transfer


2024/07/22 • 4 min. to read
With the help of the codeunit CFTFileInterfaceMgtNVX files can be exported or imported according to the CFT setup. The app can either be used in a cloud database with flows or with the extension OnPremise File Transfer for OnPremise databases allow direct file access and thus bypass the flows. Which variant is used controls which apps are installed and what is set up in the CFT setup.

Setup of Flows

The export or import flow can be started via an HTTP request to one of the Uri defined in the CFT setup. The flows send an HTTP POST or GET request to the pages released as web service in order to import a file to BC or via e.g. export a file system connector to an existing folder.

Caution

Für den Flow wird eine PowerAutomate Premium Lizenz benötigt.
You can find in the repository 2 example files for an import or export flow. ExportFile_CloudFileTransfer_Demo_20220113070553.zip ImportFile_CloudFileTransfer_Demo_20211020045958.zip In these Flows are authentifications saved. These authentifications must be changed after the import of the template. At the import flow the username and password is set in the HTTP2 step. At the export flow the username and password are set in the HTTP as well the HTTP2 steps. An Azure Active Directory application with a secret is required for the login data. Enter the data like this:

Caution

An Azure Active Directory registration must first be set up by the cloud administrators on the tenant.
Here are the references for the setup: Automation APIS Using S2S Authentication V2 OAUTH Client Creds Grant Flow An on-premise data gateway is required to access local data on the on-premises infrastructure: Gateway Reference OnPremise Data Gateway If the gateway is set up correctly, a connection can be seen in PowerAutomate.

Note

The flow is running asynchronously in the default setup. If the flow has to be executed synchronously, this could be the case if the files has to be processed directly in the code calling the flow. Then the default flow has to be extended with an response-element. In the response-element (if existing) you can set up if the flow should be executed synchronously or asynchronously. Without a response-element the flow will be executed asynchronously.

tTsting the Flows

Once set up, the flows can be tested manually. In the CFT Files files can be imported or exported manually and the flows can be started manually. For this, the respective flow must already be set up in the CFT setup. With the on-premise variant, the flows do not have to be tested, of course, because they do not exist here.

Implementation in Applications

Example code for implementation in processes. The implementation is the same for using flows or OnPremise for using direct file access.

Export

The CFT file must be created before the export and the file to be exported must be stored in it as a blob. Then the export can be started.
    procedure ExportFile(FileName: Text; FileSubPath: Text; TempBlob: Codeunit "Temp Blob");
    var
        CFTFile: Record "CFT Files NVX";
        CFTSetup: Record "CFT Setup NVX";
        FileInterfaceMgt: Codeunit CFTFileInterfaceMgtNVX;
        RecRef: RecordRef;
    begin
        CFTSetup.Get();

        CFTFile.Init();
        CFTFile.Usage := CFTFile.Usage::SCHILLPDFFileExportNVX;
        CFTFile.TransferDirection := CFTFile.TransferDirection::Export;
        CFTFile.Filename := CopyStr(FileName, 1, MaxStrLen(CFTFile.Filename));
        CFTFile.FilePath := CopyStr(FileSubPath, 1, MaxStrLen(CFTFile.FilePath));
        CFTFile.ExportType := CFTFile.ExportType::Folder;

        RecRef.GetTable(CFTFile);
        TempBlob.ToRecordRef(RecRef, CFTFile.FieldNo(FileContent));
        RecRef.SetTable(CFTFile);

        CFTFile.Insert(true);

        FileInterfaceMgt.RunFileExport(CFTSetup, CFTFile);
    end;

Import

Before importing, the files must be imported and then they can be processed. The files are imported asynchronously, which means they may not have been imported yet when they are run through as shown in the code example.
    procedure ImportAllFilesFromImportPath(ImportPath: Text)
    var
        CFTSetup: Record "CFT Setup NVX";
        FileInterfaceMgt: Codeunit CFTFileInterfaceMgtNVX;
    begin
        CFTSetup.Get();
        FileInterfaceMgt.RunFileImport(CFTSetup, ImportPath);

        CFTFile.Reset();
        CFTFile.SetRange(Usage, Usage::MyUsage);
        CFTFile.SetRange(HasValue, true);
        if CFTFile.FindSet() then
            repeat
                ProcessImportedFile(CFTFile);
            until CFTFile.Next() = 0;
    end;

See also




Submit feedback for
DE|EN Imprint