AgentStack
SKILL verified MIT Self-run

Handling Bc Files

skill-emgreppi-business-central-ai-skill-handling-bc-files · by emgreppi

Uploads and downloads files using InStream/OutStream, attaches documents to records via Table 1173, imports and exports CSV/XML with XMLport, and stores blobs in Azure Storage. Use when adding file attachments to sales orders, importing data from CSV, exporting reports to files, or connecting to Azure Blob Storage.

No reviews yet
0 installs
6 views
0.0% view→install

Install

$ agentstack add skill-emgreppi-business-central-ai-skill-handling-bc-files

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Handling Bc Files? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Skill: AL File Handling

Validation Gates

  1. After Step 1: UploadIntoStream opens file dialog, InStream contains data
  2. After Step 2: Attachment saved to Document Attachment or custom table
  3. Final: XMLport imports/exports successfully, Azure Blob upload returns IsSuccessful()

Note: ALWAYS CalcFields(BlobField) before CreateInStream. Web Client allows only ONE DownloadFromStream per request.

Procedure

Step 1: Upload/Download Files

// Upload
if UploadIntoStream('Select file', '', 'All Files (*.*)|*.*', FileName, InStr) then
    // Process InStr

// Download - MUST CalcFields first for Blob
CalcFields("File Content");
if "File Content".HasValue() then begin
    "File Content".CreateInStream(InStr);
    DownloadFromStream(InStr, '', '', '', FileName);
end;

Step 2: Document Attachments

Standard (Table 1173):

// Replace  and field names with your record
DocumentAttachment.Init();
DocumentAttachment.Validate("Table ID", Database::);
DocumentAttachment.Validate("No.", ."");
DocumentAttachment.Validate("Document Type", ."");  // If applicable
DocumentAttachment.InsertFromStream(InStr, FileName);

Custom Blob field:

Rec."File Content".CreateOutStream(OutStr);
CopyStream(OutStr, InStr);
Rec.Modify();

Step 3: XMLport Import/Export

xmlport  " Import Data"
{
    Direction = Import;
    Format = VariableText;
    FieldDelimiter = '"';
    FieldSeparator = ';';
    TextEncoding = UTF8;

    schema
    {
        textelement(Root)
        {
            tableelement(TempImport; " Import Buffer")
            {
                UseTemporary = true;
                AutoSave = false;
                fieldelement(ItemNo; TempImport."Item No.") { }
                fieldelement(Description; TempImport.Description) { }
                trigger OnAfterInsertRecord()
                begin
                    ProcessLine(TempImport);
                end;
            }
        }
    }
}

Key properties: Direction (Import/Export/Both), Format (Xml/VariableText/FixedText), TextEncoding (UTF8/UTF16)

Step 4: Azure Blob Storage (Optional)

var
    ABSBlobClient: Codeunit "ABS Blob Client";
    StorageServiceAuthorization: Codeunit "Storage Service Authorization";
    Authorization: Interface "Storage Service Authorization";
begin
    Authorization := StorageServiceAuthorization.CreateSAS(GetSASToken());
    ABSBlobClient.Initialize(AccountName, ContainerName, Authorization);

    // Upload
    TempBlob.CreateInStream(InStr);
    ABSOperationResponse := ABSBlobClient.PutBlobBlockBlobStream(BlobName, InStr);

    // Download
    ABSOperationResponse := ABSBlobClient.GetBlobAsStream(BlobName, InStr);
end;

Requires: Azure Storage Account + SAS Token in Isolated Storage.

Persistent Blob (Cross-Session)

// Store (returns GUID key)
BlobKey := PersistentBlob.Create();
PersistentBlob.CreateOutStream(OutStr);
OutStr.WriteText(Data);

// Retrieve
PersistentBlob.CreateInStream(BlobKey, InStr);
InStr.ReadText(Data);
PersistentBlob.Delete(BlobKey); // Clean up

⚠️ NOT for permanent storage - causes locking issues.

JSON/XML Quick Reference

// JSON
JsonObj.Add('key', 'value');
JsonObj.WriteTo(JsonText);
JsonObj.ReadFrom(JsonText);
if JsonObj.Get('key', JsonTok) then MyText := JsonTok.AsValue().AsText();

// XML
XmlDoc := XmlDocument.Create();
XmlDoc.Add(XmlElement.Create('Root'));
XmlDocument.ReadFrom(XmlText, XmlDoc);
XmlDoc.SelectSingleNode('//Child', XmlNode);

External Documentation

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.