Use custom metadata fields in OneDrive for Business

We are in the process of combining the SharePoint Server 2013 and SharePoint Server 2016 content into a single content set. We appreciate your patience while we reorganize things. See the Applies To tag at the top of each article to find out which version of SharePoint an article applies to.

 

Applies to: OneDrive for Business

Topic Last Modified: 2016-12-16

Learn how to add custom metadata to your files when using OneDrive for Business in Office 365.

If you want to define custom properties for your files when using OneDrive for Business in Office 365 and ensure that the metadata remains in sync between the file and your document library, you will need to enable Document Properties Promotion and Demotion to your document library in your personal site. Enabling the feature will also display the Document Information Panel in Office 2013 applications in which you can add file metadata when a file is saved to your OneDrive for Business document library.

  • Promotion is the extracting of values from file properties and writing those values to the corresponding columns in the document library in which the file is stored.

  • Demotion is the extracting of the property values from the column list and writing them to the file properties.

The following is an example of what occurs if Document Properties Promotion and Demotion is enabled in OneDrive for Business for Office 365:

  1. On the local computer, you create a document in Office 2013, give it a title of "Hardware Budget", and upload the file to your OneDrive for Business document library.

  2. You view the file in the document library, and the Title column lists "Hardware Budget".

  3. You edit the file in the document library, and change the Title property to "Hardware Budget 2015", and save the change.

  4. You download the file from the OneDrive for Business document library to your local computer (or when the next sync occurs).

  5. You view the file properties on your local computer, and the Title property should be "Hardware Budget 2015" (in sync with the changes made in the document library).

  6. When you save the file to your document library, in the Document Information Panel you change the Title property to "Hardware Budget Q1 2015".

  7. When you view the file properties in the document library, the Title column should now display as "Hardware Budget Q1 2015" (in sync with the changes made on the local computer).

The Document Properties Promotion and Demotion feature is disabled by default in Office 365 in:

  • The main document library in a new personal site.

  • The main document library in an upgraded personal site, but only if it uses the default properties and content type settings.

If Document Properties Promotion and Demotion is not enabled, you will not be prompted for file property values in the Document Information Panel when saving a file in Office 2013 to your document library. The only way you can view and edit those properties is by going to the document library and clicking View Properties (or looking at those fields in the view if the view is configured to show those fields).

NoteNote:
For more information about Document Properties Promotion and Demotion, see Document Property Promotion and Demotion Overview and Considerations.

You can use Client-side object model (CSOM) APIs to enable Document Properties Promotion and Demotion to a document library in a personal site in OneDrive for Business in Office (it is disabled by default). For this to occur, the $parserDisabledSetting property must be set to $false. The following code sample uses Windows PowerShell with the required CSOM APIs to enable the setting.

NoteNote:
You will need to download and install the SharePoint Server 2013 Client Components SDK. It contains the CSOM DLLs required for this script.

#Load the SharePoint client assemblies
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

#Set values that are used to get credentials and a SharePoint Client Context
#Replace {O365Domain} and {UserName} with your Office 365 tenant and user information
$siteUrl = "https://{O365Domain}-my.sharepoint.com/personal/{UserName}_{O365Domain}_onmicrosoft_com" 
$username = "{UserName}@{O365Domain}.onmicrosoft.com" 
#$listname value may vary for locale 
$listname = "Documents"
$parserDisabledSetting = $false
$password = Read-Host -Prompt "Enter password" -AsSecureString  

#SharePoint is accessed remotely through a client context object
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)  

#Set the credentials that the client context object uses to get authenticated access to SharePoint
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)  
$ctx.Credentials = $credentials 

#Retrieve the Documents list
$list = $ctx.Web.Lists.GetByTitle($listname)
$ctx.Load($list) 
$ctx.ExecuteQuery() 

#Read and change the parser disabled setting on the list
Write-Host "Current ParserDisabled setting is: $($list.ParserDisabled)"
Write-Host "Now setting it to: $($parserDisabledSetting)"

$list.ParserDisabled = $parserDisabledSetting
$list.Update()
$ctx.ExecuteQuery()

You may want to check the current value of the ParserDisabled property for two reasons:

  • To verify the current status of the setting prior to attempting to change it.

  • To verify that the status has actually changed after running the script to change it.

To display the value of the setting, you can run a slightly modified version of the script above (the last three lines required to save the update are removed).


#Load the SharePoint client assemblies
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

#Set values that are used to get credentials and a SharePoint Client Context 
#Replace {O365Domain} and {UserName} with your Office 365 tenant and user information
$siteUrl = "https://{O365Domain}-my.sharepoint.com/personal/{UserName}_{O365Domain}_onmicrosoft_com" 
$username = "{UserName}@{O365Domain}.onmicrosoft.com" 
#$listname value may vary for locale 
$listname = "Documents"
$parserDisabledSetting = $false
$password = Read-Host -Prompt "Enter password" -AsSecureString  

#SharePoint is accessed remotely through a client context object
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)  

#Set the credentials that the client context object uses to get authenticated access to SharePoint
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)  
$ctx.Credentials = $credentials 

#Retrieve the Documents list
$list = $ctx.Web.Lists.GetByTitle($listname)
$ctx.Load($list) 
$ctx.ExecuteQuery() 

#Read and change the parser disabled setting on the list
Write-Host "Current ParserDisabled setting is: $($list.ParserDisabled)"
Write-Host "Now setting it to: $($parserDisabledSetting)"


Show: