Auto Folder Creation (Document Library)
Module: DMS Reference, Auto Folder Creation. It drives where Document Routing auto-publish files the reviewed copy. Off by default.
How this page was verified
Traced on Medco in June 2026. On 2026-09-06 the admin screen, the reference-type list, the gating flags and the publish-time function were re-checked on master and the big five.
Overview
Auto Folder Creation lets an admin define, per project, the nested Document Library subfolder structure that reviewed documents are auto-filed into when they are published at approver sign-off. The admin picks an ordered list of document-metadata reference types (Area, Discipline, Document Type, and so on). Those become the folder levels, and each published document self-files into the branch that matches its own metadata.
It replaces the old hard-coded approach, where the folder hierarchy was one of three fixed shapes driven by a single integer, ts_projects.project_east_java (Ophir / East Java / Medco), applied at upload time by getLibCodeAutoGenerateFromDocMaster(). The structure is now data-driven and editable per project, and the filing moved to routing auto-publish. See Upload, library folder and Sign Off.
Only master, Jadestone and Medco have it
JOTRE and Timas have neither the admin screen, nor the autopublish_auto_folder_creation key, nor getProjectAutoFolderSettings(). They still have the generic custom-subfolder flags, so the default tree from subfolder_custom_default is all they can build.
What an admin configures
In DMS Reference, Auto Folder Creation (autopublish_auto_folder_creation.php), per project, the admin selects and orders any subset of the reference types in $referencesCode. The list differs per fork:
| Code stored | Label | Master | Jadestone | Medco |
|---|---|---|---|---|
areanumber | Area Code | yes | yes | yes |
discipline | Discipline Code | yes | yes | yes |
doctype | Document Type Code | yes | yes | yes |
doccat | Document Category Code | yes | yes | yes |
function_code | Function Code | yes | yes | yes |
doc_classification | Classification Code | yes | yes | yes |
field_code, group_code, contract_no | Jadestone's own references | — | yes | — |
business_unit, region, location, system_code, vendor_package, code_package_identifier, sdrl_code, drawing_category, originator | Medco's extended set | — | — | yes |
The chosen list, in order, is the folder tree. For example ["areanumber", "discipline", "doctype"] files a document into .../<Area>/<Discipline>/<Doc Type>/.
Screen actions:
- Load a project's current settings (
cmd=get_settings). - Save the selected reference list (
act=save_settingswritests_auto_creation_folder_settings.settings_dataas a JSON array). - Copy from another project (
act=copyAutoFolderSetting). - A project with no row gets the default
['discipline'].
Storage and seeding
Table
ts_auto_creation_folder_settings, one row per project:project_id,settings_data(JSON array of reference-type codes).Medco only: a one-off script,
migrations/scripts/MIG-013_ts_auto_creation_folder_settings.php, back-fills each project from its legacyproject_east_javavalue so nothing changes until an admin edits it:legacy project_east_javaseeded settings_data0(Ophir)areanumber, originator, discipline, doctype, system_code, drawing_category1(East Java)areanumber, discipline2(Medco)business_unit, region, areanumber, discipline, doctype, location, system_code, vendor_package, code_package_identifier, sdrl_codeIdempotent (TRUNCATE plus insert); projects with
project_east_javaNULL or out of range are skipped for the admin to set by hand. Master and Jadestone have no such seed; their projects start from the['discipline']default.
How it runs, at auto-publish
The structure is applied when an approver's sign-off publishes the reviewed copy, not at upload, inside autoPublishDocumentToCustomSubfoler() in routing.inc.php. The function exists in all five forks. In master the order of checks is:
- File the document into the project's Deliverables root folder (
getLibCodeDeliverablesByProjectCode()). - Only if
enable_autocreation_subfolder_custom = '1'does it build a nested subfolder. It starts from the default tree,DOCLIB_SUBFOLDER[subfolder_custom_default].tree, and, ifautopublish_auto_folder_creation = '1', overrides it with the per-project tree fromgetProjectAutoFolderSettings($projectId, true)["tree"]. - For each reference type in the tree, it resolves the document's value (
label_combined_code_desc) and finds or creates that subfolder. A level whose DMS reference flag (enable_*) is off is skipped.originatorhas noenable_*flag and is always included where it is in the list. - If any required level's value is empty, it aborts the subfolder placement (
validToSetInSubFolder = false) and the document stays at the Deliverables root. - If
library_folder_access_default = '1', it also assigns folder access to the project's resource groups.
Config flags it depends on
| Flag | Role | In the seed of |
|---|---|---|
autopublish_auto_folder_creation | Master switch for this feature: use the per-project tree, else fall back to the default tree. Default 0. | master, Jadestone, Medco |
enable_autocreation_subfolder_custom | Must be 1 for any custom subfolder to be built at all. Default 0. | all five |
subfolder_custom_default | Names the fallback tree used when the per-project feature is off. | all five |
library_folder_access_default | Auto-assign folder access to resource groups. | all five |
DMS enable_* (for example enable_discipline) | A tree level is skipped if its reference flag is off. | per fork, see inweb_config |
Both switches must be on
autopublish_auto_folder_creation alone does nothing unless enable_autocreation_subfolder_custom is also 1. The per-project tree is only consulted inside the custom-subfolder branch. Both default to 0, so the feature is off out of the box.
Database tables affected
| Table | Operation | Notes |
|---|---|---|
ts_auto_creation_folder_settings | insert / update / delete | per-project tree (admin screen) |
ts_doc_library | insert / select | find or create each subfolder at publish |
ts_map_documents_library | insert | map the published document to its leaf folder |
ts_projects | select | project_east_java, Medco's seed only |
Gotchas and known issues
- Off by default and double-gated. Easy to think it is broken when it is just not enabled.
- Medco keeps the legacy path too.
getLibCodeAutoGenerateFromDocMaster()(project_east_java) is still present and called in Medco'sactMultipleProcessNew(). The other forks no longer have that function. Confirm which governs filing on a Medco build. - Silent fallback to the Deliverables root when any tree level's value is missing on the document. No error; the document just is not nested.
- Applies at publish, not upload. A freshly uploaded, not-yet-approved document sits in the Deliverables folder until its reviewed
_Rcopy is published.
Instance differences
Checked on 2026-09-06.
| Instance | Difference |
|---|---|
| Jadestone | Reference list adds field_code, group_code and contract_no. |
| Medco | Reference list has 15 entries. Legacy project_east_java seed script and the legacy filing function are both present. |
| JOTRE | No admin screen, no autopublish_auto_folder_creation key, no getProjectAutoFolderSettings(). Only the default tree. |
| Timas | Same as JOTRE. |
Related
- Upload files into the Deliverables folder only.
- Sign Off is the auto-publish step that triggers folder creation.
- inweb_config lists the flags above.