Enforcing Metadata When Uploading Documents Via Drag And Drop In Sharepoint

Why Metadata Matters

Metadata provides critical contextual information for documents uploaded into SharePoint. This additional data allows for better organization and discovery of files stored in SharePoint libraries. However, the drag and drop upload method can bypass prompts for entering metadata. Requiring metadata helps ensure documents are properly tagged with information like document type, sensitivity, author, tags, and other attributes.

Metadata Provides Critical Context for Documents

Uploaded documents contain valuable information for an organization, but the files themselves lack context. Metadata fills this information gap by attaching descriptive attributes to documents. Details like document type, author, sensitivity, tags, title, keywords, and other metadata enable better understanding of individual documents and connections between documents.

Allows for Better Organization and Discovery

Metadata values allow for easier grouping, sorting, and filtering of documents in SharePoint. Detailed metadata improves content discoverability. For example, sensitivity metadata could automatically restrict confidential docs. Keyword and tag metadata can power search and machine learning for recommendations based on related concepts.

Drag and Drop Can Bypass Prompting for Metadata

The drag and drop upload method provides a quick way to upload documents without manually filling out forms. However, this approach skips collecting metadata upfront. Enforcing metadata requirements ensures all documents receive metadata values during upload to maintain consistency.

Setting Up Metadata Defaults

Content types provide centralized configuration to require standardized metadata across all documents. The content type definition contains details like required columns, column types, formatting, and optional defaults. All documents uploaded to libraries with that active content type automatically inherit configured rules.

Use Content Types to Require Specific Metadata Fields

Content types allow admins to mandate certain columns when uploading files into a document library. The content type ties to the library template and enforces required column values. All documents in libraries with that active content type must provide values for columns defined as required in the content type schema.

Show Example XML for Content Type Definition

  <ContentType 
    ID="0x0101001F1CEFFBD4F7F4B81858E6B7DF36047" 
    Name="Metadata Required Content Type" 
    Group="Content Types" 
    Description="Ensures metadata for uploaded docs"
    Overwrite="TRUE">
    <FieldRefs>      
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE"/>
      <FieldRef ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="Author" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE"/> 
      <FieldRef ID="{f1a1715e-6c52-40de-8102-53aa0f4278d4}" Name="Type" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE"/>
    </FieldRefs>
  </ContentType>  

Requiring Metadata on Upload

In addition to content types, document libraries also provide configuration options to require metadata. The library settings contain toggles to enable prompts for extra information when uploading files. PowerShell scripts can also set columns to mandatory before finalizing any upload to that location.

Enable Metadata Prompting on Document Libraries

Each SharePoint document library includes settings to control metadata requirements on upload. Library administrators can enable options to prompt for metadata, enforce content types, extract metadata from uploaded documents, and configure mandatory columns.

Configure Columns to Require Info Before Upload

Document libraries allow specific columns like Author or Document Type to require values before completing any upload. Library settings have toggles next to columns to define mandatory fields. Any upload skips prompting for optional metadata but forces users to enter mandatory column data.

Show PowerShell Script for Requiring Metadata

  # Define SharePoint site URL 
  $weburl = "https://contoso.sharepoint.com/sites/mydepartment"

  # Set up credentials 
  $username = "[email protected]" 
  $password = Read-Host -Prompt "Enter password" -AsSecureString 

  # Connect to site with credentials 
  Connect-PnPOnline $weburl -Credentials $username, $password 

  # Get document library 
  $list = Get-PnPList "Shared Documents" 
   
  # Set multiple columns to required 
  Set-PnPList -Identity $list -Field "Author" -Required 
  Set-PnPList -Identity $list -Field "Document Type" -Required 
  Set-PnPList -Identity $list -Field "Title" -Required

Automating Metadata Extraction

SharePoint workflows can connect to AI services to automatically classify documents and extract relevant metadata values after uploading. Workflows attach to libraries to process items, call API services, and update metadata columns.

Use SharePoint Workflows to Extract Metadata

SharePoint Designer workflows provide automation to refine and fill in metadata after documents get uploaded. Steps can analyze document content, derive metadata values like author or type, and write values back into the columns for that list item.

Connect Workflows to Microsoft Graph AI Services

Through custom actions, workflows can integrate with Microsoft Graph Cognitive Services for AI algorithms that extract deeper metadata. This includes optical character recognition, language detection, entity linking, sentiment analysis and more from content.

Include Example Workflow Definition

  <?xml version="1.0" encoding="utf-8"?>
  <Workflow 
    
     Name="Classify Documents"
     Description="Adds metadata via AI classification"
     ID="{7232D601-3232-8686-4322-F1753067D2F3}">

    <Properties>
      <!-- Store values for re-use in the workflow --> 
      <Property Id="DocumentContent" Type="String" />
      <Property Id="DetectedLanguage" Type="String" />
      <Property Id="DetectedEntities" Type="Array" />
   </Properties>

    <!-- Steps to process when items are added -->
    <OnItemAdded>
            
      <!-- Extract text content from document -->
      <GetFileContent>
           <Content>DocumentContent</Content>                     
      </GetFileContent>
          
      <!-- Call Microsoft Graph computer vision -->       
      <Callhttp WebService="https://graph.microsoft.com/v1.0/vision/ocr" ResponseContent="analysisResult" Timeout="30" RequestContent="{x:DocumentContent}">
        <Parameters>
            <!-- API key for authentication -->
            <key Name="key" Value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" /> 
        </Parameters>                
      </CallHttp>

      <!-- Extract language from result -->
      <SetWorkflowVariable Name="DetectedLanguage">
         <Variable>analysisResult["language"]</Variable>
      </SetWorkflowVariable>

      <!-- Extract detected entity names -->   
      <SetWorkflowVariable Name="DetectedEntities">
         <Variable>analysisResult["entities"]</Variable>
      </SetWorkflowVariable>
          
      <!-- Update columns with extracted metadata -->
      <UpdateListItem>
        <Field Name="Language">DetectedLanguage</Field> 
        <Field Name="Entities">DetectedEntities</Field>
      </UpdateListItem>

    </OnItemAdded>

  </Workflow>

Troubleshooting Tips

If enforced metadata requirements fail to prompt users or populate values on upload, check these key points of failure:

Check Site Columns and Content Types

Verify columns exist at the site level and content types reference those columns as required. The columns must be part of the content type bound to the list to activate rules.

Review Document Library Settings

Double check that the correct content type is associated and active for the library. Also validate required columns and prompting options are enabled in the document library settings.

Check Workflow Status and Jobs

If leveraging workflows to extract metadata, review workflow jobs for failures. Check error logs and validate connections to external services. Tuning performance of custom actions may be necessary.

Leave a Reply

Your email address will not be published. Required fields are marked *