---
title: "Extension Integration Through IWorks Common"
app: "DocXtender"
section: "How-to guides"
last_updated: "2025-01-07"
url: "https://insight-works.com/kb/docxtender/extension-integration-through-iworks-common/"
---

# Extension Integration Through IWorks Common

If you wish to create your own application to integrate with DocXtender without depending on it, you can use non-interactive uploads by naming the procedure HandleFileUpload() in IWorks Common codeunit 23044519 “IWX Common Base”. This procedure takes four parameters as seen below and triggers the event inside DocXtender to start the upload:

```
/// <summary>
    /// Proxy for firing integration event for handling file upload requests.
    /// </summary>
    /// <param name="priRecordId">The Record ID to handle the file for</param>
    /// <param name="pisInStream">The file data</param>
    /// <param name="psFileName">The name of the file</param>
    /// <param name="psSource">Identifier of where request originated from (e.g. WHI, DSHIP, etc)</param>
    procedure HandleFileUpload(priRecordId: RecordId; pisInStream: InStream; psFileName: Text; psSource: Text)
    begin
        OnFileUploaded(priRecordId, pisInStream, psFileName, psSource);
    end;
```

### Integration Events

DocXtender 2.2.1.1 contains 3 new integration events for extensions to subscribe to:

1. OnBeforeHandleNonInteractiveUpload
2. OnBeforeHandleDocumentAttachDropEvent
3. OnDropHandlerOnBeforeAttachOrUpload

The codeunit 70097825 “IWX DocXtender Sharepoint Intg” contains a new integration event _OnBeforeHandleNonInteractiveUpload._ This procedure is triggered before handling a non-interactive file upload in the procedure SaveFileToSharepointNonInteractive. It allows you to modify or check the file or current record before the file is processed. If you need to override the procedure, you can set the Handled flag to true to skip the base code.

```
  [IntegrationEvent(true, false)]
    local procedure OnBeforeHandleNonInteractiveUpload(var ptxtFullFileName: Text; var ptxtB64FileContent: Text; var pvRecToAttachLink: Variant; var pbHandled: Boolean)
    begin
    end;
```

Codeunit 70097822 “IWX DocXtender” contains two new integration events with the first being _OnBeforeHandleDocumentAttachDropEvent._ This event is triggered inside the procedure DropEvent before a document is attached to a record.

   Note: This event is not fired when using SharePoint uploads.

This event allows you to modify or perform checks on the document or related record before the attachment is processed. If you need to override the procedure, you can set the _Handled_ flag to true, which bypasses the base code and allows your extension to handle the attachment drop event instead.

```
  [IntegrationEvent(true, false)]
    procedure OnBeforeHandleDocumentAttachDropEvent(var precDocAttach: Record "Document Attachment"; var ptxtFileName: Text; var ptxtFileExtension: Text; var ptxtb64FileContent: Text; var pbHandled: Boolean)
    begin
    end;
```

The second Codeunit 70097822 “IWX DocXtender” integration event _OnDropHandlerOnBeforeAttachOrUpload_ is triggered from the document attachment FactBox, after dragging/dropping a file.

 Note: This event is triggered when using either SharePoint uploads or document attachments.

This event allows you modify or perform checks on the file or related record prior to processing the file. If you need to override the procedure, you can set the _Handled_ flag to true, preventing the base code from executing and enable your extension to take control of the upload or attachment instead.

```
 [IntegrationEvent(true, false)]
    procedure OnDropHandlerOnBeforeAttachOrUpload(var ptxtFileName: Text; var ptxtFileExtension: Text; var ptxtB64FileContent: Text; var piFileIndex: Integer; var piTotalFiles: Integer; var pbHandled: Boolean; var precrCurrentRecord: RecordRef)
    begin
    end;
```

You can use this event to override the login-based system with the non-interactive system. Use an extension containing an event subscriber with the following code to pass all uploads directly to codeunit “IWX DocXtender Sharepoint Intg”:

```
 [EventSubscriber(ObjectType::Codeunit, Codeunit::"IWX DocXtender", 'OnDropHandlerOnBeforeAttachOrUpload', '', false, false)]
    local procedure OnDropHandlerOnBeforeAttachOrUpload(var ptxtFileName: Text; var ptxtFileExtension: Text; var ptxtB64FileContent: Text;
                                                        var piFileIndex: Integer; var piTotalFiles: Integer; var pbHandled: Boolean; var precrCurrentRecord: RecordRef)
    var
        lcuSharepoint: Codeunit "IWX DocXtender Sharepoint Intg";
    begin
        if GuiAllowed() then begin
            if Dialog.Confirm('Override logins?') then begin
                pbHandled := true;
                lcuSharepoint.SaveFileToSharepointNonInteractive(ptxtFileName + ptxtFileExtension, ptxtB64FileContent, precrCurrentRecord);
            end;
        end;
    end;
```
