# Example: Update Files Without ID in Simple Mode
If you want to update existing files in simple mode for which you do not have IDs, you can either use the extended mode options, or use a custom field and workflow. In the following example, we want to add comments to already existing 4ALLPORTAL objects.
First of all, we need to find a way to make a relation between our files and our metadata. To do so, follow the following steps:
- create a custom field
- create a workflow event to handle the custom field
- map custom field values into the upload file
# Create a Custom Field
- Navigate to admin snap-in
Module configurations/Files/Fields
- Create a unique field of type
External ID
and make sure it is aNative field
- we're going to give it the name ext_id
# Create a Workflow Event
To learn how to create your own workflow event, please follow this guide (opens new window).
For our example, we will create the following XML in folder modules/file/workflow_events/{name}.xml
, and give it the name ext_id_handler.xml:
<?xml version="1.0" encoding="UTF-8"?>
<workflow_event>
<on_create>true</on_create>
<on_update>true</on_update>
<description></description>
<trigger_fields>
<trigger_field>mount</trigger_field>
<trigger_field>name</trigger_field>
<trigger_field>parent_path</trigger_field>
</trigger_fields>
<actions>
<action class="com.cm4ap.ce.workflow.action.MetadataMappingAction">
<parameters>
<entry key="ext_id" class="com.cm4ap.ce.vo.workflow.action.MetadataMappingConf">
<template>{$mount}:{$parent_path}/{$name}</template>
</entry>
</parameters>
</action>
</actions>
</workflow_event>
This handler will write our conditional value which will be {$mount}:{$parent_path}/{$name}
, to the created field ext_id.
To create your own template (conditional value), please follow this guide (opens new window).
The values of {$mount}
, {$parent_path}
, and {$name}
will be assigned automatically from the field values in the database.
For example, if the file photo.png is stored in folder data/Folder/photo.png
, the result will be data:Folder/photo.png
.
Before mapping our fields to the upload file, we must upload our files to the desired destination.
For our example, we will upload img.jpg
, img1.jpg
, and img2.jpg
to folder data/csv_import/
:
In the database, our field is defined and has taken its values.
# Map Custom Field Values Into the Upload File
To map ext_id into e.g., an Excel sheet, create a column with the name ext_id beside your metadata field names, and pass the value in it:
We want to import our comments into 4ALLPORTAL, once that is done, save your file and import it using the CSV Import.
Now your files' metadata is updated. Enjoy! 😉