---
title: "Document Viewer"
id: "document-viewer"
project: "MES User Manual"
url: "https://docs.sepasoft.com/articles/user-manual/document-viewer"
updated: 2026-07-31T14:56:08Z
---

# Document Viewer

**Sepasoft MES Module Suite**

## Document Management in an OEE Production Run

This example uses the Document Management components for Perspective to create an OEE Production Run that displays input fields within a document. A production run is initiated, and that document is loaded. The document inputs are handled and saved, and the production run is ended.

![](/resources/Storage/user-manual/document-viewer/image%20%2817%29.png)

| ![Success](/resources/Storage/user-manual/Success.png) | Required items and configuration to complete the steps below:<br><ul style="margin-left: 40px;"><li>Modules Installed<ul><li>Production</li><li>OEE</li><li>Document Management</li></ul></li><li>Configuration</li><li style="margin-left: 40px;">Material created and configured to run on a Line for OEE</li></ul> |
| --- | --- |

### 

### 

### Configuring Document Management in Designer

#### 

You create and edit documents with the Document Editor in design-time and view documents in the Document Viewer component at runtime. In the system, documents are artifacts that are attached to MES Objects. This example uses the MES Object Selector component with the Document Editor to associate a Line MES object to a document artifact. Then, uses the Document Viewer to display instructions with input fields during an OEE run. The input values are printed to the console.

####  Setting Up a Document Editor in a Perspective View

* In Ignition Designer on a Perspective View, add an **MES Object Selector component**.
* Set the property **includeMESLineObjects** to True.
* Add a **Document Editor Component**, and bind the editor to the selector:


```
../mesObjectSelector.props.selectedMESObject
```

#### 

#### Creating and Saving a Document

Create a document artifact with text fields and checkboxes. The document is saved and later loaded during the production run.

* In Designer, in **Play** mode, select a **Line** in the **MES Object Selector**.
* Create a document with text fields and checkboxes.
* Add a name to the **selectedArtifactName property** and then in the design area, click **Play** and then the **Save icon in the Document Editor**.

![](/resources/Storage/user-manual/document-viewer/image%20%2813%29.png)

#### Scripts and Methods for Document Handling

In Ignition Designer, design a Perspective View like this one:

![](/resources/Storage/user-manual/document-viewer/runtime-view.png)

| ![](/resources/Storage/user-manual/document-viewer/1.png) | Add a Label and a Text Entry. Keep the property defaults and name them. |
| --- | --- |
| ![](/resources/Storage/user-manual/document-viewer/2.png) | <ul><li>Add a <b>Document Viewer component</b> from the Perspective Component Palette.</li><li>Select the Document Viewer, right click and select <b>Configure Events...</b></li><li>Add the script below to the <b>d</b><b>ocumentSaved</b> event.<br></li></ul>
```python
def runAction(self, event):
    message = event['inputValues']
    system.perspective.print(message)
    
    self.props.selectedMESObject = ''
    self.props.selectedArtifactName = ''
    self.props.showSaveButton = False
```
<br>![](/resources/Storage/user-manual/document-viewer/image%20%2810%29.png) |
| ![](/resources/Storage/user-manual/document-viewer/3.png) | **Start Production Run Functionality**<br><br>The script initializes a production run using OE downtime, equipment path, and material name.<br><ul><li>Add a <b>Start Production Run</b> button.&#160;</li><li>Add the script below to the <b>onActionPerformed</b> event.</li><li>Make sure Line and material name match your configuration. And Apply and Save.</li></ul>
```python
def runAction(self, event):
    eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
    matName = 'Blend77'
    
    seg = system.mes.oee.beginOEERun(matName, eqPath)
    system.mes.oee.endOEEChangeover(eqPath)
```
![](/resources/Storage/user-manual/document-viewer/image%20%2815%29.png)<br><br><br>**Load and Save Document**<br><br>The script loads a master document using the getArtifactValueByName method. The script saves the document inputs and updates the document viewer component.<br>* Add a **Load Copy of Master Document** button.<br>* Add the script below to the **onActionPerformed** event.<br><br><br>| ![Success](/resources/Storage/user-manual/Success.png) | Notice the end of the script where a dictionary is built. The Document Viewer needs these functions to return the name-value pairs.<br><br>**See in the code:**<br><br>##Build this dictionary for the doc viewer component selected MES Object<br><br>##Pass the dictionary to the viewer and the document name to the viewer |<br>| --- | --- |<br><br><br>![](/resources/Storage/user-manual/document-viewer/image%20%2816%29.png)<br><br><br><br>
```python
def runAction(self, event):
    ##Get Relevant information:
    eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
    matName = 'Blend77'
    docName = self.getSibling("TextField").props.text
    
    ##Load the Line where the document master is found:
    eq = system.mes.loadMESObjectByEquipmentPath(eqPath)
    ##Retrieve the Document
    docValue = eq.getArtifactValueByName(docName)
    
    ##Load the Response Segment that is currently running:
    segs = system.mes.getCurrentSegments(eqPath)
    seg = segs.get(0).getMESObject()
    
    ##Create the Artifact with the loaded document on the current Response Segment:
    ##Note this could be repeated with different names for the document if multiple docs of the same type 
    ##would be associated with the same response segment.
    seg.createArtifact(docName, docValue, 1)
    seg = seg.update()
    
    ##Build this dictionary for the doc viewer component selected MES Object:
    dict = {"mesObjectUUID":seg.getUUID(),"mesObjectType":seg.getMESObjectTypeName(),"equipmentPath":"","name":seg.getName(),"disabled":False,"childCount":-1}
        
    ##Pass the dictionary to the viewer and the document name to the viewer    
    self.getSibling("docDocumentViewer").props.selectedMESObject = dict
    self.getSibling("docDocumentViewer").props.selectedArtifactName = docName
    self.getSibling("docDocumentViewer").props.showSaveButton = True
```
<br><br><br><br>**End Production**<br>* Add a **End Production Run** button.<br>* Add the script below to the **onActionPerformed** event.<br><br><br>
```python
def runAction(self, event):
    eqPath = 'Enterprise\Site\Area\Dark Chocolate Line'
    matName = 'Blend77'
    
    system.mes.oee.endOEEProduction(eqPath)
```
<br><br><br>**Remove Artifact**<br><br>The script removes an artifact from an MES object using the remove complex property method.<br>* Add a **Remove Artifact** button.<br>* Add the script below to the **onActionPerformed** event.<br><br><br>
```python
def runAction(self, event):
    ##Load the object where the artifact resides
    ##e.g. the Line, Response Segment, Material, etc.
    obj = system.mes.loadMESObject('Material 1', 'MaterialDef')
    ##An Artifact is a complex property within the MES Object Model, so remove the complex property of type "Artifact":
    obj.removeComplexProperty('Artifact','Specific Artifact Name')
    ##Save your changes to the object you've modified
    system.mes.saveMESObject(obj)
```
 |

#### Run an OEE and add values. Look at the console for values.

* On the Perspective View where the Document Viewer is and in Play mode, click **Start Production Run**.
* Then, click **Load Copy of Master Document**.

![](/resources/Storage/user-manual/document-viewer/image%20%2814%29.png)

* Enter some values in the document. Then save the document by clicking the checkmark at the bottom of the page.
* Click **End Production Run**.
* Click **Remove Artifact**.

Notice in the Output Console, the name-value pairs that represent the form element and its value.

![](/resources/Storage/user-manual/document-viewer/document-viewer-2024-08-02.png)

**Sepasoft MES Module Suite**