Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get Document Library's Managed Metadata Field Default Value

$
0
0

Hi All,

I need help to read default value of managed metadata field of a document library using powershell. I am able to set default value in powershell and can view default value in doc library settings but I get null value when I try to read default value using powershell.

echo $spList["Record Classification"].DefaultValue

even tried

$field = $spList.Fields.GetField("Record Classification") -as [Microsoft.SharePoint.Taxonomy.TaxonomyField]
echo $field.DefaultValue

I am using the following code to set default value of this field.

               

$term = GetTerm -siteColl $spWeb.Site

                    if ($term)
                    {   
                        $cDef = New-Object Microsoft.Office.DocumentManagement.MetadataDefaults($spList)
                        $cDef.SetFieldDefault($spList.RootFolder, $spList.Fields["Record Classification"].InternalName,$spWeb.Language.ToString() + ";#" + $term.Name + "|" + $term.Id)
                        $cDef.Update();
                        write-host $term.Name " set as Record Classification column's default value in " $spList.Title " document library" -foregroundcolor DarkCyan    
                    }

Any ideas?

Amar


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>