Purpose
The Map Folder Name to Field function will automatically set a default value of a metadata column based on the name of the SharePoint folder a file is being saved to.
An example of where this can be useful would be if your libraries have a sub folder for each document type (e.g. Memo or Letter) and you would like all files saved to that folder to have their Document Type choice metadata column set automatically as you save to that location.
How it works
Map Folder Name to Field can be configured to set the value of any of the following field types to the name of the folder where a document is being saved.
- Choice
- Lookup
- Managed Metadata
- Multiple lines of text
- Multi Choice
- Multi Lookup
- Multi Managed Metadata
- Number
- Single Line of Text
When a document is saved to SharePoint using DMF or Message, if all the configured conditions are met the default value of the configured columns will be set to match the name of the folder or document set it is being saved to.
Configuration
The settings that dictate when the Map Folder Name to Field plugin will take affect are specified either in the registry, or in DMF 8.8.520 or later in a configuration file stored in your central configuration (resource library) location.
Configuration via the registry
The key to be setup are located under the following registry branch.
HKEY_CURRENT_USER\Software\MacroView\DMF\Customizations\MacroView\MapFolderNameToFieldValue
Root Registry Settings
The root key “MapFolderNameToFieldValue” has two available settings:
- Disable
- 0 = Enables the extension (default).
- 1 = Disables the extension.
- EnableMultiple
- 0 = Will only attempt to map and set 1 Field for the targeted Content Type (default).
- 1 = Will attempt to map multiple Fields (if the mapping matches the filter criteria).
The root key also has a subkey named “TargetContentTypes”.
Targeted Content Types Subkey
The TargetContentTypes subkey is a container for each target Content Type the user wishes to use for the Field mappings.
Each Content Type Field map must be in its own subkey. The mapping subkeys can have arbitrary names, however when searching for a matching ContentType->Field map, the search is performed in sequential order. If “EnableMultiple” is disabled (set to 0); the extension will select the first available map that matches. Therefore it’s recommended to name the subkeys in a fashion that represents preferential ordering (i.e. 1, 2, 3 ,4 etc).
Targeted Content Types Registry Settings
Each target Content Type subkey has 14 configurable settings.
Note - If any of the “Allowed” settings are left blank, all Sites, hosts, container types or Lists that are not in the corresponding “Ignore” setting will pass the filtering process.
If an “Allowed” setting is not blank (contains one or more items); only those specified in the “Allowed” setting will pass the filtering process.
- AllowedContainerTypes
A list of allowed container types where the folder name value can be “pulled” from (i.e. Folder, Document Set, Matter Document Set) (default = blank).
- AllowedHosts
A list of allowed servers / hosts, to limit which host the extension will function on (do not include protocol of server; http or https ) e.g. (contoso.com or localhost:8080) (default = blank).
- AllowedLists
A list of allowed SharePoint Lists the extension will trigger on (default = blank).
- AllowedRootContainerTypes
A list of allowed container types for the “Allowed Container”. This setting is used to restrict mapping to subfolders within a folder or document set (i.e. Site->Library->…/…./RootContainer->Container) it is NOT recursive, and will only restrict the parent of the “Allowed Container”.
Format when setting up 2 content types:
- AllowedSites
A list of SharePoint Webs using the web server relative URL (e.g. /sites/TestSite) (default = blank).
- ContentTypeName
ContentType name for the mapping (i.e. Document, or Matter Document).
- Disable
Boolean trigger to disable the individual mapping (useful for a temporary disable) (default = 0).
- IgnoreCase
Boolean trigger to enable / disable case sensitive matching (default = 0), set to 1 for ignore case sensitivity.
- IgnoredContainerTypes
List of container type to ignore (e.g. Folder, Document Set).
- IgnoredHosts
List of hosts / servers to ignore.
- IgnoredLists
List of SharePoint Lists to ignore.
- IgnoredRootContainerTypes
List of Root / Parent container types to ignore (see AllowedRootContainerTypes for more information).
- IgnoredSites
List of SharePoint Webs to ignore (using server relative URL).
- MapToFieldInternalName
Internal Field name of the target ContentType Field to map the folder name value on success.
Note: this value is case sensitive e.g. mvDocumentType
Compulsory Registry Settings
The only compulsory / required Registry settings for each targeted Field map are:
- ContentTypeName
- MapToFieldInternalName
Default Configuration
By default Map Folder Name to Field is configured for use with MacroView Case and Matter so that it only applies when saving documents to folders within a Matter Document Set using the Matter Document content type containing a metadata or choice column for Document Type.
Mapping to multiple levels in a nested folder structure
If your folder structure reflects the metadata to be applied to files as they are saved, MapFolderNameToField can be configured to handle this by adding each folder level below the to the MapToFieldInternalName settings separated by backslashes.
For example, in a folder structure like the following, you can map each folder level to a different metadata column.
AllowedRootContainerTypes is required to be blank if you want to save files after the Document Set(Matter) further down the nested folders.
You can also include extra backslashes to indicate additional level without, even if there is no metadata to be set for some of the levels. For the example above, "/" is added the beginning to indicate the document set level without including it in the properties. i.e. /mvDocumentTypeC/Animal/Line1
You can use the above approach to also only set the metadata for particular folder levels. For example setting MapToFieldInternalName to /mvDocumentTypeC//Line1 in the example above would only set the Document Type and Line1 metadata values.
Configuration via a JSON configuration file
MacroView DMF versions 8.8.520 and later support using a configuration file to deploy these settings.
The expected config filename/path is in the MacroView AppData store location “Extensions\MapFolderNameToFieldValue\configuration.json.config”
To deploy the file from the Central Configuration Location create a Folder in your Central Resource library called "MapFolderNameToFieldValue" and save the configuration file to that locaton.
Download a sample configuration file.
The difference between the registry configuration and the JSON configuration file is mostly the filtering format.
In this sample JSON configuration file the AllowedContainerTypes + IgnoredContainerTypes are combined in a dictionary object “ContainerFilters”. Similarly with AllowedRootContainerTypes/IgnoredRootContainerTypes, AllowedLists/IgnoredLists, AllowedSites/IgnoredSites and AllowedHosts/IgnoredHosts.
To add a filter type as “allowed”, the name/key is set as the object property name (e.g., “Document Set”) and the value is set to true (or false for Ignored filter types).
Note: multiple content types need to be separated by a comma.
Configuration File Syntax
{
"Disabled": false,
"EnableMultipleMapping": false,
"TargetContentTypes": [
{
"Disabled" : false,
"ContentTypeName": "Document",
"FieldInternalNames": [
"ManagedSingle",
"SingleTextField"
],
"IgnoreCase": false,
"ContainerFilters": {
"Document Set": false,
"Folder": true,
"DocSet2": false
},
"ContainerParentFilters": {
"Document Set": true,
"DocSet2": false,
"Folder": false
},
"ListFilters": {
"DocSetLibrary1": true,
"DocSetLibrary2": false
},
"SiteFilters": {
"/sites/Dev2/Testing": true
},
"HostFilters": {
"https://macroview365.sharepoint.com": true
}
}
]
}
Enable Fallback Path Value
8.9.1061 and later has added additional functionality to Map Folder Name to Field.
Configuration File Syntax
Example
Column internal names

Restricted Matching
From 8.9.1067 and later MapFolderNameToFieldValue will be able to restrict matching (based on Path) for Taxonomy fields.
Note: If both a configuration file and registry settings are defined the configuration files will override the registry
Note: Host Filter must include 'https://'
Version Support
MacroView DMF or MacroView Message 8.6.103 or later
MacroView DMF versions 8.8.520 and later support using a configuration file to deploy these settings.