# 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`. | ## How It Works **New File Event** from 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. 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_ServiceName` is set with a service signature, and the key `FileRaw_DEEActionName` is not set, a MES Service will be called. !!! 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.