none
In a document library, can you show a site column in the 2nd Upload Document form, but not in the Edit Properties form? RRS feed

  • Question

  • In a document library (not for a list), is it possible to display a site column in the 2nd Upload Document form, but not in the Edit Properties form?

    When I upload a new document, I would like a site column (say ABC) to be displayed in the 2nd Upload Document form that gets displayed after you click on the Files tab | Upload Document button | click Browse and choose a file. e.g. c:\temp\test.docx file | click Ok, i.e. the form in the screenshot below

    but I do not want the site column (say ABC) to appear when you select Edit Properties for the document.

    The PowerShell script below is what I am currently using, but does not display the site column in the 2nd Upload Document form. Could this be because the document has already been uploaded, and hence $field.ShowInNewForm = $true is not applicable to this form?

    function MakeFieldInSiteCollectionNotEditable ($strSiteCollection, $strInternalFieldName)
    {
        try
        {
            Write-Host "Make Field $($strInternalFieldName) in site collection $($strSiteCollection) not editable"
            $site = Get-SPSite $strSiteCollection
            $web = $site.RootWeb

            # Refer to
            # 1. https://andrewwburns.com/2010/04/13/hide-a-custom-field-from-the-dip/
            # 2. https://sharepoint.stackexchange.com/questions/91082/how-do-i-show-a-field-in-dispform-thats-been-hidden-in-content-type
            # 3. https://rmanimaran.wordpress.com/2010/11/09/sharepoint-setting-showinfiledlg-using-object-model/
            # 4. http://stackoverflow.com/questions/24284773/how-to-hide-sharepoint-2013-managed-metadata-column-in-document-information-pane
            #    and http://www.howtobuildsoftware.com/index.php/how-do/cfx7/sharepoint-ms-word-sharepoint-2013-customcolumn-how-to-hide-sharepoint-2013-managed-metadata-column-in-document-information-panel
            #    - Confirmed bug you cannot hide managed metadata fields in the DIP
            # 5. http://get-spscripts.com/2010/08/show-and-hide-columns-in-sharepoint.html

            # Get the field $strInternalFieldName
            $field = $web.Fields.GetFieldByInternalName($strInternalFieldName)

            # Do not show in DIP, Document Information Panel, when viewing in Office
            [xml]$xml = $field.SchemaXml
            $a = $xml.CreateAttribute("ShowInFileDlg")
            $a.Value = "FALSE"
            $f = $xml.SelectSingleNode("Field")
            $f.Attributes.Append($a) > $null
            $field.SchemaXml = $f.OuterXml
            # Set the PushChangesToLists property for the changes to be applied to lists where the column has already been added. Note $field.PushChangesToLists = $true is the same as $field.Update($true)
            $field.PushChangesToLists = $true
            $field.Update($true)

            # Do not show in Edit Form, but show in New Form
            $field.ShowInNewForm = $true # c.f. https://msdn.microsoft.com/en-us/library/dd588183(v=office.11).aspx -  In particular, this is used to hide fields on the document library upload document page.
            $field.ShowInEditForm = $false
            # Set the PushChangesToLists property for the changes to be applied to lists where the column has already been added. Note $field.PushChangesToLists = $true is the same as $field.Update($true)
            $field.PushChangesToLists = $true
            $field.Update($true)

            $web.Update()

            $web.Dispose()
            $site.Dispose()
        }
        catch
        {
            Write-Host "[ERROR] in MakeFieldInSiteCollectionNotEditable - Field $($strInternalFieldName) in site collection $($strSiteCollection) with error $($_.Exception)" "red"
        }
    }

    Thank you!!



    • Edited by s l ng Tuesday, May 2, 2017 7:15 AM
    Tuesday, May 2, 2017 7:13 AM

Answers

  • Hi,

    The 2nd upload document form is the Edit Properties form(Edit Item form) in the library. When you click Edit Properties in the ribbon, it opens the same form. The form is just used in both the two scenarios.

    The two forms are just one form in the library, so it is not supported to show a column in 2nd upload form but not show on Edit Properties form.

    In addition, to show a column in Edit Item form, we need to make sure that the column has been added to the library. And then set the column to show in Edit Item form.

    http://get-spscripts.com/2010/08/show-and-hide-columns-in-sharepoint.html

    Best Regards,

    Victoria

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by s l ng Thursday, May 4, 2017 11:52 AM
    Wednesday, May 3, 2017 11:49 AM
    Moderator

All replies

  • Hi,

    The 2nd upload document form is the Edit Properties form(Edit Item form) in the library. When you click Edit Properties in the ribbon, it opens the same form. The form is just used in both the two scenarios.

    The two forms are just one form in the library, so it is not supported to show a column in 2nd upload form but not show on Edit Properties form.

    In addition, to show a column in Edit Item form, we need to make sure that the column has been added to the library. And then set the column to show in Edit Item form.

    http://get-spscripts.com/2010/08/show-and-hide-columns-in-sharepoint.html

    Best Regards,

    Victoria

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by s l ng Thursday, May 4, 2017 11:52 AM
    Wednesday, May 3, 2017 11:49 AM
    Moderator
  • Hi Victoria, Thank you for your helping to answer my question. 
    Thursday, May 4, 2017 11:53 AM