# New File Event ## Overview This feature enables the processing of a New File Event in the watched folder. ## How To Configure ### Relevant Artifacts The table below describes the properties for this entity type: | Name | Type | Is Mandatory | Data Type | Description | | :-------------------- | :--------- | :----------: | :-------- | :----------------------------------------------- | | IoTMetadataDefinition | SmartTable | Yes | | Metadata configuration for equipment integration | ### IoTMetadataDefinition Resource Level Configuration At the **Resource** level, there are several configurations we can edit to change the behavior of this feature. | Resource | Resource Type | Area | Name | Value | Description | | ----------------------- | ------------- | ---- | -------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | *MES FileRaw Resource* | | | **FileRaw_DeleteOnSuccess** | True or False | If the file will be deleted after successfully processing. | | *MES FileRaw Resource* | | | **FileRaw_DEEActionName** | DEE Name | Name of the DEE that should be called to handle the parsed file content. | | *MES FileRaw Resource* | | | **FileRaw_ServiceName** | Service Signature | Signature of the service to be called to handle the parsed file content. | | *MES FileRaw Resource* | | | **FileRaw_convertToJson** | True or False | Should be set if the file content is multi line format, like CSV. The content will be converted to a JSON array, used with the key FileRaw_fieldSeparator. | | *MES FileRaw Resource* | | | **FileRaw_fieldSeparator** | Char | Character used as a value separator. | | *MES FileRaw Resource* | | | **FileRaw_UseXML2JSON** | True or False | Should be set if the file content is in XML format. | | *MES FileRaw Resource* | | | **FileRaw_ArchiveWithTimestamp** | True or False | Should be set to False if you don't want the file name to be modified during moving operations. Default: `true`. | | *MES FileRaw Resource* | | | **FileRaw_DEEActionNameRetries** | Number | Number of attempts the DEE should be called if a retriable error is thrown. | | *MES FileRaw Resource* | | | **FileRaw_FilterByName** | String | String by which a file is filtered in or out by its name. | | *MES FileRaw Resource* | | | **FileRaw_FilterByContent** | String | String by which a file is filtered in or out by its content. | ## How It Works **New File Event** from **FileRaw** protocol is triggered. The File content will be Read and Parsed and the Content will be passed to the defined *Service* or *DEE*. * If File content is JSON Object no keys are needed for parsing. * If File content is in XML format the key `FileRaw_UseXML2JSON` should be set to true. With this the XML will be converted to a JSON Object before being sent to MES. * If File content is a multiline format, like CSV, the key `FileRaw_convertToJson` should be set to true and the key `FileRaw_fieldSeparator` should be set with the corresponding separator Char. * If the key `FileRaw_FilterByName` is set to a value, the workflow is responsible for filtering the file through its name. * If the key `FileRaw_FilterByContent` is set to a value, the workflow is responsible for filtering the file through its content. The Controller will call MES *Service* or *DEE* according to what is defined. * If `FileRaw_DEEActionName` is set with the name of a DEE it will be called. * If `FileRaw_DEEActionNameRetries` is set to a value, the DEE invocation will be retried up to this number of times when a retriable error occurs. * If `FileRaw_ServiceName` is set with a service signature, and the key `FileRaw_DEEActionName` is not set, a MES Service will be called. !!! info "Retriable Errors" The following errors are considered retriable and will trigger a new attempt, up to the number of times defined in `FileRaw_DEEActionNameRetries`: * **Object changed since last viewed**: The data for the object has changed since last viewed and needs to be refreshed. * **Deadlock**: The process was deadlocked on lock resources with another process. * **Host down**: The connection to the host was refused (`ECONNREFUSED`). !!! Warning "The Inputs for both the Service and DEE Must be as follows" **ResourceName**: Name of the Resource connected to that GenericFileIntegration_Controller instance. **FileName**: Name of the file read. **FileContent**: Parsed JSON content. ### Post-processing After the file is processed on of this will happen: * If correctly processed in IoT layer and no errors occurred in MES the system will perform one of these actions: * Move the File to the Archive Success Folder defined, check [Setup](setup.md) for more information. * Delete the File if `FileRaw_DeleteOnSuccess` is set as **true**. * If error occurs during IoT processing or in MES call the file will be moved to Archive Error Folder defined in , check [Setup](setup.md) for more information, and a log will be generated in a timestamped folder with the Error information.