Skip to content

Create Document Relationships

Introduction

The following functionalities facilitate the creation and management of document relationships within your specific domains. This allows documents associated with Record 1 through a relation to also be displayed under Record 2.

To utilize these functions, it is essential to have a Connector App, Document Central, and your own application set as a dependency. This ensures seamless integration and access to the following features.

Establishing a Document Relationship within a Single Event or Function

Document relationships can be established within a single event or function, provided that the source and target references are correctly determined.

SetSourceRelation and SetTargetRelation

The functions are used to define the source and target of the relationship.

AL
1
2
3
4
5
6
7
8
var
    LocalCodeunitSIMDMSDocRelationshipMgt: Codeunit "SIM_DMS Doc. Relationship Mgt";
    LocalSourceRecordRef: RecordRef;
    LocalTargetRecordRef: RecordRef;
begin
    LocalCodeunitSIMDMSDocRelationshipMgt.SetSourceRelation(LocalSourceRecordRef);
    LocalCodeunitSIMDMSDocRelationshipMgt.SetTargetRelation(LocalTargetRecordRef);
end;

Establishing Document Relationships in a Workflow

The following two functions allow the creation of document relationships in a workflow. This approach enables the definition of source and target documents in separate events or functions.

This function defines the source document. It should be invoked within an EventSubscriber where the source document is available.

SetSourceRelationByDocRelation

The functions is used to define the source document. Call this function in an EventSubscriber where the source document exists.

AL
1
2
3
4
5
6
7
8
9
var
    LocalRecordSIMDMSDocumentRelationship: Record "SIM_DMS Document Relationship";
    LocalCodeunitSIMDMSDocRelationshipMgt: Codeunit "SIM_DMS Doc. Relationship Mgt";
    LocalCodeunitSIMDMSSI: Codeunit "SIM_DMS SI";
    LocalRecordRef: RecordRef;
begin
    LocalCodeunitSIMDMSDocRelationshipMgt.SetSourceRelationByDocRelation(LocalRecordSIMDMSDocumentRelationship, LocalRecordRef);
    LocalCodeunitSIMDMSSI.SetDocRelation(LocalRecordSIMDMSDocumentRelationship);
end;

SetTargetRelationByDocRelation

This function is responsible for defining the target document. It should be called within an EventSubscriber where the target document exists.

AL
1
2
3
4
5
6
7
8
9
var
    LocalRecordSIMDMSDocumentRelationship: Record "SIM_DMS Document Relationship";
    LocalCodeunitSIMDMSDocRelationshipMgt: Codeunit "SIM_DMS Doc. Relationship Mgt";
    LocalCodeunitSIMDMSSI: Codeunit "SIM_DMS SI";
    LocalRecordRef: RecordRef;
begin
    LocalCodeunitSIMDMSSI.GetDocRelation(LocalRecordSIMDMSDocumentRelationship);
    LocalCodeunitSIMDMSDocRelationshipMgt.SetTargetRelationByDocRelation(LocalRecordSIMDMSDocumentRelationship, LocalRecordRef);
end;

Description of the Code

It is important to note that these function calls must be executed in combination. The Source Relationship and Target Relationship must be set within a single process to ensure the creation of a valid document relationship.

Application Example

These functions are particularly valuable when extending custom areas where Document Central does not provide standard access. A practical example includes industry-specific solutions that require additional document relationship management capabilities.

Advantages

Enhanced Flexibility: Ensures documents are displayed in the appropriate areas, improving accessibility and organization.

Seamless Integration: Allows for document relationships to be established dynamically within workflows.

Scalability: Supports industry-specific customizations beyond standard functionalities.